Update tests
This commit is contained in:
parent
f9a6a179d1
commit
43dae3ed9b
1 changed files with 13 additions and 13 deletions
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var expect = require('expect.js');
|
var expect = require('expect.js');
|
||||||
var gradientParser = require('gradient-parser');
|
var gradients = require('index');
|
||||||
|
|
||||||
// [
|
// [
|
||||||
// {
|
// {
|
||||||
|
@ -36,56 +36,56 @@ describe('gradient-parser.js', function () {
|
||||||
subject;
|
subject;
|
||||||
|
|
||||||
it('should exist', function () {
|
it('should exist', function () {
|
||||||
expect(typeof gradientParser).to.equal('function');
|
expect(typeof gradients.parse).to.equal('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('error cases', function() {
|
describe('error cases', function() {
|
||||||
it('one more comma in definitions', function() {
|
it('one more comma in definitions', function() {
|
||||||
expect(function() {
|
expect(function() {
|
||||||
gradientParser('linear-gradient(red, blue),');
|
gradients.parse('linear-gradient(red, blue),');
|
||||||
}).to.throwException(/One extra comma/);
|
}).to.throwException(/One extra comma/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('one more comma in colors', function() {
|
it('one more comma in colors', function() {
|
||||||
expect(function() {
|
expect(function() {
|
||||||
gradientParser('linear-gradient(red, blue,)');
|
gradients.parse('linear-gradient(red, blue,)');
|
||||||
}).to.throwException(/Expected color definition/);
|
}).to.throwException(/Expected color definition/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('invalid input', function() {
|
it('invalid input', function() {
|
||||||
expect(function() {
|
expect(function() {
|
||||||
gradientParser('linear-gradient(red, blue) aaa');
|
gradients.parse('linear-gradient(red, blue) aaa');
|
||||||
}).to.throwException(/Invalid input not EOF/);
|
}).to.throwException(/Invalid input not EOF/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('missing open call', function() {
|
it('missing open call', function() {
|
||||||
expect(function() {
|
expect(function() {
|
||||||
gradientParser('linear-gradient red, blue');
|
gradients.parse('linear-gradient red, blue');
|
||||||
}).to.throwException(/Missing \(/);
|
}).to.throwException(/Missing \(/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('missing comma before color stops', function() {
|
it('missing comma before color stops', function() {
|
||||||
expect(function() {
|
expect(function() {
|
||||||
gradientParser('linear-gradient(to right red, blue)');
|
gradients.parse('linear-gradient(to right red, blue)');
|
||||||
}).to.throwException(/Missing comma before color stops/);
|
}).to.throwException(/Missing comma before color stops/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('missing color stops', function() {
|
it('missing color stops', function() {
|
||||||
expect(function() {
|
expect(function() {
|
||||||
gradientParser('linear-gradient(to right, )');
|
gradients.parse('linear-gradient(to right, )');
|
||||||
}).to.throwException(/Expected color definition/);
|
}).to.throwException(/Expected color definition/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('missing closing call', function() {
|
it('missing closing call', function() {
|
||||||
expect(function() {
|
expect(function() {
|
||||||
gradientParser('linear-gradient(to right, red, blue aaa');
|
gradients.parse('linear-gradient(to right, red, blue aaa');
|
||||||
}).to.throwException(/Missing \)/);
|
}).to.throwException(/Missing \)/);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when parsing a simple definition', function() {
|
describe('when parsing a simple definition', function() {
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
ast = gradientParser('linear-gradient(red, blue)');
|
ast = gradients.parse('linear-gradient(red, blue)');
|
||||||
subject = ast[0];
|
subject = ast[0];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ describe('gradient-parser.js', function () {
|
||||||
['px', 'em', '%'].forEach(function(metric) {
|
['px', 'em', '%'].forEach(function(metric) {
|
||||||
describe('parse color stop for metric '+ metric, function() {
|
describe('parse color stop for metric '+ metric, function() {
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
ast = gradientParser('linear-gradient(blue 10' + metric + ', transparent)');
|
ast = gradients.parse('linear-gradient(blue 10' + metric + ', transparent)');
|
||||||
subject = ast[0];
|
subject = ast[0];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ describe('gradient-parser.js', function () {
|
||||||
].forEach(function(orientation) {
|
].forEach(function(orientation) {
|
||||||
describe('parse orientation ' + orientation.type, function() {
|
describe('parse orientation ' + orientation.type, function() {
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
ast = gradientParser('linear-gradient(' + orientation.unparsedValue + ', blue, green)');
|
ast = gradients.parse('linear-gradient(' + orientation.unparsedValue + ', blue, green)');
|
||||||
subject = ast[0].orientation;
|
subject = ast[0].orientation;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ describe('gradient-parser.js', function () {
|
||||||
].forEach(function(color) {
|
].forEach(function(color) {
|
||||||
describe('parse color type '+ color.type, function() {
|
describe('parse color type '+ color.type, function() {
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
ast = gradientParser('linear-gradient(12deg, ' + color.unparsedValue + ', blue, green)');
|
ast = gradients.parse('linear-gradient(12deg, ' + color.unparsedValue + ', blue, green)');
|
||||||
subject = ast[0].colorStops[0];
|
subject = ast[0].colorStops[0];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue