* Also ensures `assert.equal` is always in the right order.
exports.commandsSuite = vows.describe('binary commands').addBatch({
'no options': binaryContext('', {
'should output help': function(stdout) {
- assert.equal(/Usage:/.test(stdout), true);
+ assert.match(stdout, /Usage[:]/);
}
}),
'help': binaryContext('-h', {
'should output help': function(error, stdout) {
- assert.equal(/Usage:/.test(stdout), true);
+ assert.match(stdout, /Usage[:]/);
},
'should output one file example': function(error, stdout) {
- assert.equal(stdout.indexOf('cleancss -o one-min.css one.css') > -1, true);
+ assert.include(stdout, 'cleancss -o one-min.css one.css');
},
'should output multiple files example': function(error, stdout) {
- assert.equal(stdout.indexOf('cat one.css two.css three.css | cleancss -o merged-and-minified.css') > -1, true);
+ assert.include(stdout, 'cat one.css two.css three.css | cleancss -o merged-and-minified.css');
},
'should output gzipping multiple files example': function(error, stdout) {
- assert.equal(stdout.indexOf('cat one.css two.css three.css | cleancss | gzip -9 -c > merged-minified-and-gzipped.css.gz') > -1, true);
+ assert.include(stdout, 'cat one.css two.css three.css | cleancss | gzip -9 -c > merged-minified-and-gzipped.css.gz');
}
}),
'version': binaryContext('-v', {
}),
'to output file with debug info': pipedContext('a{color: #f00;}', '-d -o debug.css', {
'should output nothing to stdout and debug info to stderr': function(error, stdout, stderr) {
- assert.equal(stdout, '');
+ assert.isEmpty(stdout);
assert.notEqual(stderr, '');
assert.include(stderr, 'Time spent:');
assert.include(stderr, 'Original: 16 bytes');
}),
'no relative to path': binaryContext('./test/data/partials-absolute/base.css', {
'should not be able to resolve it fully': function(error, stdout, stderr) {
- assert.equal(stdout, '');
+ assert.isEmpty(stdout);
assert.notEqual(error, null);
assert.notEqual(stderr, '');
}
}),
'to file': binaryContext('-o ./reset1-min.css ./test/data/reset.css', {
'should give no output': function(error, stdout) {
- assert.equal(stdout, '');
+ assert.isEmpty(stdout);
},
'should minimize': function() {
- var minimized = readFile('./test/data/reset-min.css');
- var target = readFile('./reset1-min.css');
- assert.equal(minimized, target);
+ var preminified = readFile('./test/data/reset-min.css');
+ var minified = readFile('./reset1-min.css');
+ assert.equal(minified, preminified);
},
teardown: function() {
deleteFile('./reset1-min.css');
'complex import and url rebasing': {
absolute: binaryContext('-r ./test/data/129-assets ./test/data/129-assets/assets/ui.css', {
'should rebase urls correctly': function(error, stdout) {
- assert.equal(error, null);
+ assert.isNull(error);
assert.include(stdout, 'url(/components/bootstrap/images/glyphs.gif)');
assert.include(stdout, 'url(/components/jquery-ui/images/prev.gif)');
assert.include(stdout, 'url(/components/jquery-ui/images/next.gif)');
'complex import and skipped url rebasing': {
absolute: binaryContext('-r ./test/data/129-assets --skip-rebase ./test/data/129-assets/assets/ui.css', {
'should rebase urls correctly': function(error, stdout) {
- assert.equal(error, null);
+ assert.isNull(error);
assert.include(stdout, 'url(../images/glyphs.gif)');
assert.include(stdout, 'url(../images/prev.gif)');
assert.include(stdout, 'url(../images/next.gif)');
},
'of a file': binaryContext('http://127.0.0.1:31991/present.css', {
succeeds: function(error, stdout) {
- assert.equal(error, null);
+ assert.isNull(error);
assert.equal(stdout, 'p{font-size:13px}');
}
}),
assert.include(stderr, 'Broken @import declaration of "http://localhost:24682/timeout.css" - timeout');
},
'should output empty response': function(error, stdout) {
- assert.equal(stdout, '');
+ assert.isEmpty(stdout);
},
teardown: function() {
this.server.close();
var cssContext = function(groups, options) {
var context = {};
- var clean = function(expectedCss) {
- return function(css) {
- var minifiedCss = new CleanCSS(options).minify(css).styles;
- assert.equal(minifiedCss, expectedCss);
+ var clean = function (expected) {
+ return function (source) {
+ var minified = new CleanCSS(options).minify(source).styles;
+ assert.equal(minified, expected);
};
};
new CleanCSS().minify('a{color:#f00}', this.callback);
},
'should not set context': function() {
- assert.equal(false, this instanceof CleanCSS);
+ assert.equal(this instanceof CleanCSS, false);
},
'should yield no error': function(errors, minified) {
/* jshint unused: false */
- assert.equal(errors, null);
+ assert.isNull(errors);
},
'should yield minified data': function(errors, minified) {
assert.equal(minified.styles, 'a{color:red}');
},
'should yield no error and minify': function(errors, minified) {
/* jshint unused: false */
- assert.equal(errors.length, 1);
+ assert.lengthOf(errors, 1);
}
},
'no debug': {
'topic': new CleanCSS().minify('a{ color: #f00 }'),
'should not populate stats hash': function (error, minified) {
- assert.deepEqual({}, minified.stats);
+ assert.isEmpty(minified.stats);
}
},
'debug': {
'no warnings': {
'topic': new CleanCSS().minify('a{ color: #f00 }'),
'if no reasons given': function (error, minified) {
- assert.deepEqual(minified.warnings, []);
+ assert.isEmpty(minified.warnings);
}
},
'warnings': {
'topic': new CleanCSS({ root: 'test/data', target: 'custom-warnings.css' }).minify('a{color:red}'),
+ 'are an array': function (error, minified) {
+ assert.isArray(minified.warnings);
+ },
'if both root and output used reasons given': function (error, minified) {
- assert.equal(minified.warnings.length, 1);
+ assert.lengthOf(minified.warnings, 1);
assert.match(minified.warnings[0], /Both 'root' and output file given/);
}
},
assert.equal(minified.styles, 'a{display:block}');
},
'should raise no errors': function (error, minified) {
- assert.equal(minified.errors.length, 0);
+ assert.isEmpty(minified.errors);
},
'should raise one warning': function (error, minified) {
- assert.equal(minified.warnings.length, 1);
+ assert.lengthOf(minified.warnings, 1);
assert.equal(minified.warnings[0], 'Unexpected \'}\' in \'a{display:block}}\'. Ignoring.');
}
},
assert.equal(minified.styles, 'a{display:block}p{color:red}');
},
'should raise no errors': function (error, minified) {
- assert.equal(minified.errors.length, 0);
+ assert.isEmpty(minified.errors);
},
'should raise one warning': function (error, minified) {
- assert.equal(minified.warnings.length, 1);
+ assert.lengthOf(minified.warnings, 1);
assert.equal(minified.warnings[0], 'Unexpected content: \'color:#535353}\'. Ignoring.');
}
},
'warnings on invalid properties': {
'topic': new CleanCSS().minify('a{color:}'),
'should minify correctly': function (error, minified) {
- assert.equal(minified.styles, '');
+ assert.isEmpty(minified.styles);
},
'should raise no errors': function (error, minified) {
- assert.equal(minified.errors.length, 0);
+ assert.isEmpty(minified.errors);
},
'should raise one warning': function (error, minified) {
- assert.equal(minified.warnings.length, 1);
+ assert.lengthOf(minified.warnings, 1);
assert.equal(minified.warnings[0], 'Empty property \'color\' inside \'a\' selector. Ignoring.');
}
},
assert.equal(minified.styles, 'a{background:url(image/}');
},
'should raise no errors': function (error, minified) {
- assert.equal(minified.errors.length, 0);
+ assert.isEmpty(minified.errors.length);
},
'should raise one warning': function (error, minified) {
- assert.equal(minified.warnings.length, 1);
+ assert.lengthOf(minified.warnings, 1);
assert.equal(minified.warnings[0], 'Broken URL declaration: \'url(image/\'.');
}
},
'warnings on broken imports': {
'topic': new CleanCSS().minify('@impor'),
'should output correct content': function (error, minified) {
- assert.equal(minified.styles, '');
+ assert.isEmpty(minified.styles);
},
'should raise no errors': function (error, minified) {
- assert.equal(minified.errors.length, 0);
+ assert.isEmpty(minified.errors.length);
},
'should raise one warning': function (error, minified) {
- assert.equal(minified.warnings.length, 1);
+ assert.lengthOf(minified.warnings, 1);
assert.equal(minified.warnings[0], 'Broken declaration: \'@impor\'.');
}
},
'warnings on broken comments': {
'topic': new CleanCSS().minify('a{}/* '),
'should output correct content': function (error, minified) {
- assert.equal(minified.styles, '');
+ assert.isEmpty(minified.styles);
},
'should raise no errors': function (error, minified) {
- assert.equal(minified.errors.length, 0);
+ assert.isEmpty(minified.errors.length);
},
'should raise one warning': function (error, minified) {
- assert.equal(minified.warnings.length, 1);
+ assert.lengthOf(minified.warnings, 1);
assert.equal(minified.warnings[0], 'Broken comment: \'/* \'.');
}
},
'no errors': {
'topic': new CleanCSS().minify('a{color:red}'),
'if no reasons given': function (error, minified) {
- assert.deepEqual(minified.errors, []);
+ assert.isEmpty(minified.errors);
}
},
'errors': {
'topic': new CleanCSS(),
'if both root and output used reasons given': function(minifier) {
- assert.doesNotThrow(function() {
- minifier.minify('@import url(/some/fake/file);', function(errors) {
- assert.equal(errors.length, 1);
+ assert.doesNotThrow(function () {
+ minifier.minify('@import url(/some/fake/file);', function (errors) {
+ assert.isArray(errors);
+ assert.lengthOf(errors, 1);
assert.equal(errors[0], 'Broken @import declaration of "/some/fake/file"');
});
});
'if both root and output used reasons given': function (minifier) {
minifier.minify('@import url(/some/fake/file);');
minifier.minify('@import url(/some/fake/file);', function(errors) {
- assert.equal(errors.length, 1);
+ assert.lengthOf(errors, 1);
assert.equal(errors[0], 'Broken @import declaration of "/some/fake/file"');
});
}
return new CleanCSS().minify(new Buffer('@import url(test/data/partials/one.css);'));
},
'should be processed correctly': function(minified) {
- assert.equal('.one{color:red}', minified.styles);
+ assert.equal(minified.styles, '.one{color:red}');
}
},
'options': {
'advanced': {
'topic': new CleanCSS({ advanced: true }).minify('a{color:red}a{color:#fff}'),
'gets right output': function (minified) {
- assert.equal('a{color:#fff}', minified.styles);
+ assert.equal(minified.styles, 'a{color:#fff}');
}
},
'aggressive merging': {
'topic': new CleanCSS({ aggressiveMerging: true }).minify('a{display:block;color:red;display:inline-block}'),
'gets right output': function (minified) {
- assert.equal('a{color:red;display:inline-block}', minified.styles);
+ assert.equal(minified.styles, 'a{color:red;display:inline-block}');
}
},
'process import': {
'topic': new CleanCSS({ processImport: true }).minify('@import url(/test/data/partials/one.css);'),
'gets right output': function (minified) {
- assert.equal('.one{color:red}', minified.styles);
+ assert.equal(minified.styles, '.one{color:red}');
}
},
'rebase': {
'source map': {
'topic': new CleanCSS({ sourceMap: true }).minify('/*! a */div[data-id=" abc "] { color:red; }'),
'should minify correctly': function (minified) {
- assert.equal('/*! a */div[data-id=" abc "]{color:red}', minified.styles);
+ assert.equal(minified.styles, '/*! a */div[data-id=" abc "]{color:red}');
},
'should include source map': function (minified) {
assert.instanceOf(minified.sourceMap, SourceMapGenerator);
new CleanCSS().minify('@import url(http://127.0.0.1/missing.css);a{color:red}', this.callback);
},
'should raise error': function(errors, minified) {
- assert.equal(errors.length, 1);
+ assert.lengthOf(errors, 1);
},
'should ignore @import': function(errors, minified) {
assert.equal(minified.styles, '@import url(http://127.0.0.1/missing.css);a{color:red}');
},
teardown: function() {
- assert.equal(this.reqMocks.isDone(), true);
+ assert.isTrue(this.reqMocks.isDone());
nock.cleanAll();
}
},
assert.equal(minified.styles, 'p{font-size:13px}a{color:red}');
},
teardown: function() {
- assert.equal(this.reqMocks.isDone(), true);
+ assert.isTrue(this.reqMocks.isDone());
nock.cleanAll();
}
},
assert.equal(minified.styles, 'p{font-size:13px}');
},
teardown: function() {
- assert.equal(this.reqMocks.isDone(), true);
+ assert.isTrue(this.reqMocks.isDone());
nock.cleanAll();
}
},
assert.equal(minified.styles, 'p{font-size:13px}a{color:red}');
},
teardown: function() {
- assert.equal(this.reqMocks.isDone(), true);
+ assert.isTrue(this.reqMocks.isDone());
nock.cleanAll();
}
},
assert.equal(minified.styles, '@media screen{p{font-size:13px}}a{color:red}');
},
teardown: function() {
- assert.equal(this.reqMocks.isDone(), true);
+ assert.isTrue(this.reqMocks.isDone());
nock.cleanAll();
}
},
assert.equal(minified.styles, 'body{margin:0}div{padding:0}p{font-size:13px}a{color:red}');
},
teardown: function() {
- assert.equal(this.reqMocks1.isDone(), true);
- assert.equal(this.reqMocks2.isDone(), true);
+ assert.isTrue(this.reqMocks1.isDone());
+ assert.isTrue(this.reqMocks2.isDone());
nock.cleanAll();
}
},
assert.equal(minified.styles, 'body{margin:0}p{font-size:13px}a{color:red}');
},
teardown: function() {
- assert.equal(this.reqMocks.isDone(), true);
+ assert.isTrue(this.reqMocks.isDone());
nock.cleanAll();
}
},
new CleanCSS().minify('@import url(http://127.0.0.1/nested/present.css);a{color:red}', this.callback);
},
'should not raise errors': function(errors, minified) {
- assert.equal(errors.length, 1);
+ assert.lengthOf(errors, 1);
assert.equal(errors[0], 'Broken @import declaration of "http://127.0.0.1/missing.css" - error 404');
},
'should process @import': function(errors, minified) {
assert.equal(minified.styles, '@import url(http://127.0.0.1/missing.css);p{font-size:13px}a{color:red}');
},
teardown: function() {
- assert.equal(this.reqMocks.isDone(), true);
+ assert.isTrue(this.reqMocks.isDone());
nock.cleanAll();
}
},
assert.equal(minified.styles, 'a{background:url(http://127.0.0.1/test.png)}');
},
teardown: function() {
- assert.equal(this.reqMocks.isDone(), true);
+ assert.isTrue(this.reqMocks.isDone());
nock.cleanAll();
}
},
assert.equal(minified.styles, 'a{background:url(http://127.0.0.1/deeply/images/test.png)}');
},
teardown: function() {
- assert.equal(this.reqMocks.isDone(), true);
+ assert.isTrue(this.reqMocks.isDone());
nock.cleanAll();
}
},
assert.equal(minified.styles, 'a{background:url(../images/test.png)}');
},
teardown: function() {
- assert.equal(this.reqMocks.isDone(), true);
+ assert.isTrue(this.reqMocks.isDone());
nock.cleanAll();
}
},
new CleanCSS().minify('@import url(http://notdefined.127.0.0.1/custom.css);a{color:red}', this.callback);
},
'should not raise errors': function(errors, minified) {
- assert.equal(errors.length, 1);
+ assert.lengthOf(errors, 1);
assert.include(errors[0], 'Broken @import declaration of "http://notdefined.127.0.0.1/custom.css"');
},
'should process @import': function(errors, minified) {
assert.equal(minified.styles, 'body{margin:0}a{color:red}');
},
teardown: function() {
- assert.equal(this.reqMocks.isDone(), true);
+ assert.isTrue(this.reqMocks.isDone());
nock.cleanAll();
}
},
assert.equal(minified.styles, 'body{margin:0}a{color:red}');
},
teardown: function() {
- assert.equal(this.reqMocks.isDone(), true);
+ assert.isTrue(this.reqMocks.isDone());
nock.cleanAll();
}
},
});
},
'should raise errors': function(errors, minified) {
- assert.equal(errors.length, 1);
+ assert.lengthOf(errors, 1);
assert.equal(errors[0], 'Broken @import declaration of "http://localhost:' + port + '/timeout.css" - timeout');
},
'should process @import': function(errors, minified) {
assert.equal(minified.styles, 'body{margin:0}div{padding:0}a{color:red}');
},
teardown: function() {
- assert.equal(this.reqMocks.isDone(), true);
+ assert.isTrue(this.reqMocks.isDone());
nock.cleanAll();
}
},
assert.equal(minified.styles, 'div{padding:0}a{color:red}');
},
teardown: function() {
- assert.equal(this.reqMocks.isDone(), true);
+ assert.isTrue(this.reqMocks.isDone());
nock.cleanAll();
}
},
assert.equal(minified.styles, 'div{padding:0}a{color:red}');
},
teardown: function() {
- assert.equal(this.reqMocks.isDone(), true);
+ assert.isTrue(this.reqMocks.isDone());
nock.cleanAll();
}
},
assert.equal(minified.styles, 'div{padding:0}.one{color:red}');
},
teardown: function() {
- assert.equal(this.reqMocks.isDone(), true);
+ assert.isTrue(this.reqMocks.isDone());
nock.cleanAll();
}
},
assert.isEmpty(minified.errors);
},
'should raise warnings': function (error, minified) {
- assert.equal(minified.warnings.length, 1);
+ assert.lengthOf(minified.warnings, 1);
assert.match(minified.warnings[0], /no callback given/);
},
'should process @import': function (error, minified) {
assert.equal(minified.styles, '@import url(http://127.0.0.1/remote.css);.one{color:red}');
},
teardown: function() {
- assert.equal(this.reqMocks.isDone(), false);
+ assert.isFalse(this.reqMocks.isDone());
nock.cleanAll();
}
}
'module #1': {
'topic': new CleanCSS({ sourceMap: true }).minify('/*! a */div[data-id=" abc "] { color:red; }'),
'should have 2 mappings': function(minified) {
- assert.equal(2, minified.sourceMap._mappings.length);
+ assert.lengthOf(minified.sourceMap._mappings, 2);
},
'should have selector mapping': function (minified) {
var mapping = {
source: '__stdin__.css',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[0]);
+ assert.deepEqual(minified.sourceMap._mappings[0], mapping);
},
'should have body mapping': function (minified) {
var mapping = {
source: '__stdin__.css',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[1]);
+ assert.deepEqual(minified.sourceMap._mappings[1], mapping);
}
},
'module #2': {
'topic': new CleanCSS({ sourceMap: true }).minify('@media screen {\n@font-face \n{ \nfont-family: test; } }'),
'should have 3 mappings': function(minified) {
- assert.equal(3, minified.sourceMap._mappings.length);
+ assert.lengthOf(minified.sourceMap._mappings, 3);
},
'should have @media mapping': function (minified) {
var mapping = {
source: '__stdin__.css',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[0]);
+ assert.deepEqual(minified.sourceMap._mappings[0], mapping);
},
'should have @font-face mapping': function (minified) {
var mapping = {
source: '__stdin__.css',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[1]);
+ assert.deepEqual(minified.sourceMap._mappings[1], mapping);
},
'should have font-family mapping': function (minified) {
var mapping = {
source: '__stdin__.css',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[2]);
+ assert.deepEqual(minified.sourceMap._mappings[2], mapping);
}
},
'with keepBreaks': {
'topic': new CleanCSS({ sourceMap: true, keepBreaks: true }).minify('@media screen { a{color:red} p {color:blue} }div{color:pink}'),
'should have 7 mappings': function(minified) {
- assert.equal(7, minified.sourceMap._mappings.length);
+ assert.lengthOf(minified.sourceMap._mappings, 7);
},
'should have @media mapping': function (minified) {
var mapping = {
source: '__stdin__.css',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[0]);
+ assert.deepEqual(minified.sourceMap._mappings[0], mapping);
},
'should have _a_ mapping': function (minified) {
var mapping = {
source: '__stdin__.css',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[1]);
+ assert.deepEqual(minified.sourceMap._mappings[1], mapping);
},
'should have _color:red_ mapping': function (minified) {
var mapping = {
source: '__stdin__.css',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[2]);
+ assert.deepEqual(minified.sourceMap._mappings[2], mapping);
},
'should have _p_ mapping': function (minified) {
var mapping = {
source: '__stdin__.css',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[3]);
+ assert.deepEqual(minified.sourceMap._mappings[3], mapping);
},
'should have _color:blue_ mapping': function (minified) {
var mapping = {
source: '__stdin__.css',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[4]);
+ assert.deepEqual(minified.sourceMap._mappings[4], mapping);
},
'should have _div_ mapping': function (minified) {
var mapping = {
source: '__stdin__.css',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[5]);
+ assert.deepEqual(minified.sourceMap._mappings[5], mapping);
},
'should have _color:pink_ mapping': function (minified) {
var mapping = {
source: '__stdin__.css',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[6]);
+ assert.deepEqual(minified.sourceMap._mappings[6], mapping);
}
},
'shorthands': {
'topic': new CleanCSS({ sourceMap: true }).minify('a{background:url(image.png);background-color:red}'),
'should have 3 mappings': function(minified) {
- assert.equal(3, minified.sourceMap._mappings.length);
+ assert.lengthOf(minified.sourceMap._mappings, 3);
},
'should have selector mapping': function (minified) {
var mapping = {
source: '__stdin__.css',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[0]);
+ assert.deepEqual(minified.sourceMap._mappings[0], mapping);
},
'should have _background_ mapping': function (minified) {
var mapping = {
source: '__stdin__.css',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[1]);
+ assert.deepEqual(minified.sourceMap._mappings[1], mapping);
},
'should have _background-color_ mapping': function (minified) {
var mapping = {
source: '__stdin__.css',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[2]);
+ assert.deepEqual(minified.sourceMap._mappings[2], mapping);
}
},
'keyframes': {
'topic': new CleanCSS({ sourceMap: true }).minify('@-webkit-keyframes frames {\n 0% {\n border: 1px;\n }\n 100% {\n border: 3px;\n }\n}'),
'should have 5 mappings': function(minified) {
- assert.equal(5, minified.sourceMap._mappings.length);
+ assert.lengthOf(minified.sourceMap._mappings, 5);
},
'should have _@keframes_ mapping': function (minified) {
var mapping = {
source: '__stdin__.css',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[0]);
+ assert.deepEqual(minified.sourceMap._mappings[0], mapping);
},
'should have _0%_ mapping': function (minified) {
var mapping = {
source: '__stdin__.css',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[1]);
+ assert.deepEqual(minified.sourceMap._mappings[1], mapping);
},
'should have _border:1px_ mapping': function (minified) {
var mapping = {
source: '__stdin__.css',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[2]);
+ assert.deepEqual(minified.sourceMap._mappings[2], mapping);
},
'should have _100%_ mapping': function (minified) {
var mapping = {
source: '__stdin__.css',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[3]);
+ assert.deepEqual(minified.sourceMap._mappings[3], mapping);
},
'should have _border:3px_ mapping': function (minified) {
var mapping = {
source: '__stdin__.css',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[4]);
+ assert.deepEqual(minified.sourceMap._mappings[4], mapping);
}
},
'double comments': {
'topic': new CleanCSS({ sourceMap: true }).minify('/* COMMENT 1 */\n/* COMMENT 2 */\ndiv{color:red}'),
'should have 2 mappings': function(minified) {
- assert.equal(2, minified.sourceMap._mappings.length);
+ assert.lengthOf(minified.sourceMap._mappings, 2);
},
'should have _div__ mapping': function (minified) {
var mapping = {
source: '__stdin__.css',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[0]);
+ assert.deepEqual(minified.sourceMap._mappings[0], mapping);
},
'should have _color:red_ mapping': function (minified) {
var mapping = {
source: '__stdin__.css',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[1]);
+ assert.deepEqual(minified.sourceMap._mappings[1], mapping);
}
}
})
'input map as string': {
'topic': new CleanCSS({ sourceMap: inputMap }).minify('div > a {\n color: red;\n}'),
'should have 2 mappings': function (minified) {
- assert.equal(2, minified.sourceMap._mappings.length);
+ assert.lengthOf(minified.sourceMap._mappings, 2);
},
'should have selector mapping': function (minified) {
var mapping = {
source: 'styles.less',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[0]);
+ assert.deepEqual(minified.sourceMap._mappings[0], mapping);
},
'should have _color:red_ mapping': function (minified) {
var mapping = {
source: 'styles.less',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[1]);
+ assert.deepEqual(minified.sourceMap._mappings[1], mapping);
}
},
'input map from source': {
'topic': new CleanCSS({ sourceMap: true }).minify('div > a {\n color: red;\n}/*# sourceMappingURL=' + inputMapPath + ' */'),
'should have 2 mappings': function (minified) {
- assert.equal(2, minified.sourceMap._mappings.length);
+ assert.lengthOf(minified.sourceMap._mappings, 2);
},
'should have selector mapping': function (minified) {
var mapping = {
source: 'styles.less',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[0]);
+ assert.deepEqual(minified.sourceMap._mappings[0], mapping);
},
'should have _color:red_ mapping': function (minified) {
var mapping = {
source: 'styles.less',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[1]);
+ assert.deepEqual(minified.sourceMap._mappings[1], mapping);
}
},
'input map from source with root': {
'topic': new CleanCSS({ sourceMap: true, relativeTo: path.dirname(inputMapPath) }).minify('div > a {\n color: red;\n}/*# sourceMappingURL=styles.css.map */'),
'should have 2 mappings': function (minified) {
- assert.equal(2, minified.sourceMap._mappings.length);
+ assert.lengthOf(minified.sourceMap._mappings, 2);
},
'should have selector mapping': function (minified) {
var mapping = {
source: 'styles.less',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[0]);
+ assert.deepEqual(minified.sourceMap._mappings[0], mapping);
},
'should have _color:red_ mapping': function (minified) {
var mapping = {
source: 'styles.less',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[1]);
+ assert.deepEqual(minified.sourceMap._mappings[1], mapping);
}
},
'complex input map': {
'topic': new CleanCSS({ sourceMap: true, root: path.dirname(inputMapPath) }).minify('@import url(import.css);'),
'should have 4 mappings': function (minified) {
- assert.equal(4, minified.sourceMap._mappings.length);
+ assert.lengthOf(minified.sourceMap._mappings, 4);
},
'should have first selector mapping': function (minified) {
var mapping = {
source: 'some.less',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[0]);
+ assert.deepEqual(minified.sourceMap._mappings[0], mapping);
},
'should have _color:red_ mapping': function (minified) {
var mapping = {
source: 'some.less',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[1]);
+ assert.deepEqual(minified.sourceMap._mappings[1], mapping);
},
'should have second selector mapping': function (minified) {
var mapping = {
source: 'styles.less',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[2]);
+ assert.deepEqual(minified.sourceMap._mappings[2], mapping);
},
'should have _color:blue_ mapping': function (minified) {
var mapping = {
source: 'styles.less',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[3]);
+ assert.deepEqual(minified.sourceMap._mappings[3], mapping);
}
},
'complex input map referenced by path': {
'topic': new CleanCSS({ sourceMap: true }).minify('@import url(test/data/source-maps/import.css);'),
'should have 4 mappings': function (minified) {
- assert.equal(4, minified.sourceMap._mappings.length);
+ assert.lengthOf(minified.sourceMap._mappings, 4);
}
},
'complex but partial input map referenced by path': {
'topic': new CleanCSS({ sourceMap: true, target: process.cwd() }).minify('@import url(test/data/source-maps/no-map-import.css);'),
'should have 4 mappings': function (minified) {
- assert.equal(4, minified.sourceMap._mappings.length);
+ assert.lengthOf(minified.sourceMap._mappings, 4);
},
'should have 2 mappings to .less file': function (minified) {
var fromLess = minified.sourceMap._mappings.filter(function (mapping) {
return mapping.source == path.join('test', 'data', 'source-maps', 'styles.less');
});
- assert.equal(2, fromLess.length);
+ assert.lengthOf(fromLess, 2);
},
'should have 2 mappings to .css file': function (minified) {
var fromCSS = minified.sourceMap._mappings.filter(function (mapping) {
return mapping.source == path.join('test', 'data', 'source-maps', 'no-map.css');
});
- assert.equal(2, fromCSS.length);
+ assert.lengthOf(fromCSS, 2);
}
},
'complex input map with an existing file as target': {
'topic': new CleanCSS({ sourceMap: true, target: path.join(process.cwd(), 'test', 'data', 'source-maps', 'styles.css') }).minify('@import url(test/data/source-maps/styles.css);'),
'should have 2 mappings': function (minified) {
- assert.equal(2, minified.sourceMap._mappings.length);
+ assert.lengthOf(minified.sourceMap._mappings, 2);
},
'should have 2 mappings to styles.less file': function (minified) {
var stylesSource = minified.sourceMap._mappings.filter(function (mapping) {
return mapping.source == 'styles.less';
});
- assert.equal(2, stylesSource.length);
+ assert.lengthOf(stylesSource, 2);
},
},
'nested once': {
'topic': new CleanCSS({ sourceMap: true }).minify('@import url(test/data/source-maps/nested/once.css);'),
'should have 2 mappings': function (minified) {
- assert.equal(minified.sourceMap._mappings.length, 2);
+ assert.lengthOf(minified.sourceMap._mappings, 2);
},
'should have "section > div a" mapping': function (minified) {
var mapping = {
source: 'once.less',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[0]);
+ assert.deepEqual(minified.sourceMap._mappings[0], mapping);
},
'should have "color:red" mapping': function (minified) {
var mapping = {
source: 'once.less',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[1]);
+ assert.deepEqual(minified.sourceMap._mappings[1], mapping);
}
},
'nested twice': {
'topic': new CleanCSS({ sourceMap: true }).minify('@import url(test/data/source-maps/nested/twice.css);'),
'should have 2 mappings': function (minified) {
- assert.equal(minified.sourceMap._mappings.length, 2);
+ assert.lengthOf(minified.sourceMap._mappings, 2);
},
'should have "body > nav a" mapping': function (minified) {
var mapping = {
source: 'twice.less',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[0]);
+ assert.deepEqual(minified.sourceMap._mappings[0], mapping);
},
'should have "color:red" mapping': function (minified) {
var mapping = {
source: 'twice.less',
name: null
};
- assert.deepEqual(mapping, minified.sourceMap._mappings[1]);
+ assert.deepEqual(minified.sourceMap._mappings[1], mapping);
}
}
})
assert.isDefined(minified.sourceMap);
},
'raises an error': function(errors, _) {
- assert.equal(errors.length, 1);
+ assert.lengthOf(errors, 1);
assert.equal(errors[0], 'Broken source map at "http://127.0.0.1/remote.css.map" - 404');
},
teardown: function () {
- assert.equal(this.reqMocks.isDone(), true);
+ assert.isTrue(this.reqMocks.isDone());
nock.cleanAll();
}
},
assert.isDefined(minified.sourceMap);
},
'raises an error': function(errors, _) {
- assert.equal(errors.length, 1);
+ assert.lengthOf(errors, 1);
assert.equal(errors[0], 'Broken source map at "http://127.0.0.1:' + port + '/remote.css.map" - timeout');
},
teardown: function () {
assert.equal(minified.sourceMap._mappings[0].source, 'http://127.0.0.1/styles.less');
},
teardown: function () {
- assert.equal(this.reqMocks.isDone(), true);
+ assert.isTrue(this.reqMocks.isDone());
nock.cleanAll();
}
},
assert.isDefined(minified.sourceMap);
},
teardown: function () {
- assert.equal(this.reqMocks.isDone(), true);
+ assert.isTrue(this.reqMocks.isDone());
nock.cleanAll();
}
},
assert.isDefined(minified.sourceMap);
},
teardown: function () {
- assert.equal(this.reqMocks.isDone(), true);
+ assert.isTrue(this.reqMocks.isDone());
nock.cleanAll();
}
},
assert.isDefined(minified.sourceMap);
},
teardown: function () {
- assert.equal(this.reqMocks.isDone(), true);
+ assert.isTrue(this.reqMocks.isDone());
nock.cleanAll();
}
}
function processorContext(name, context, keepSpecialComments, keepBreaks, saveWaypoints) {
var vowContext = {};
- function escaped (targetCSS) {
- return function (sourceCSS) {
- var result = new CommentsProcessor(null, keepSpecialComments, keepBreaks, saveWaypoints).escape(sourceCSS);
- assert.equal(result, targetCSS);
+ function escaped (expected) {
+ return function (source) {
+ var escaped = new CommentsProcessor(null, keepSpecialComments, keepBreaks, saveWaypoints).escape(source);
+ assert.equal(escaped, expected);
};
}
- function restored (targetCSS) {
- return function (sourceCSS) {
+ function restored (expected) {
+ return function (source) {
var processor = new CommentsProcessor(null, keepSpecialComments, keepBreaks, saveWaypoints);
- var result = processor.restore(processor.escape(sourceCSS));
- assert.equal(result, targetCSS);
+ var restored = processor.restore(processor.escape(source));
+ assert.equal(restored, expected);
};
}
function processorContext(name, context, saveWaypoints) {
var vowContext = {};
- function escaped (targetCSS) {
- return function (sourceCSS) {
- var result = new ExpressionsProcessor(saveWaypoints).escape(sourceCSS);
- assert.equal(result, targetCSS);
+ function escaped (expected) {
+ return function (source) {
+ var escaped = new ExpressionsProcessor(saveWaypoints).escape(source);
+ assert.equal(escaped, expected);
};
}
- function restored (targetCSS) {
- return function (sourceCSS) {
+ function restored (expected) {
+ return function (source) {
var processor = new ExpressionsProcessor(saveWaypoints);
- var result = processor.restore(processor.escape(sourceCSS));
- assert.equal(result, targetCSS);
+ var restored = processor.restore(processor.escape(source));
+ assert.equal(restored, expected);
};
}
function processorContext(name, context, saveWaypoints) {
var vowContext = {};
- function escaped (targetCSS) {
- return function (sourceCSS) {
- var result = new FreeTextProcessor(saveWaypoints).escape(sourceCSS);
- assert.equal(result, targetCSS);
+ function escaped (expected) {
+ return function (source) {
+ var escaped = new FreeTextProcessor(saveWaypoints).escape(source);
+ assert.equal(escaped, expected);
};
}
- function restored (targetCSS) {
- return function (sourceCSS) {
+ function restored (expected) {
+ return function (source) {
var processor = new FreeTextProcessor(saveWaypoints);
- var result = processor.restore(processor.escape(sourceCSS));
- assert.equal(result, targetCSS);
+ var restored = processor.restore(processor.escape(source));
+ assert.equal(restored, expected);
};
}
function processorContext(name, context, saveWaypoints) {
var vowContext = {};
- function escaped (targetCSS) {
- return function (sourceCSS) {
- var result = new UrlsProcessor(null, saveWaypoints).escape(sourceCSS);
- assert.equal(result, targetCSS);
+ function escaped (expected) {
+ return function (source) {
+ var escaped = new UrlsProcessor(null, saveWaypoints).escape(source);
+ assert.equal(escaped, expected);
};
}
- function restored (targetCSS) {
- return function (sourceCSS) {
+ function restored (expected) {
+ return function (source) {
var processor = new UrlsProcessor(null, saveWaypoints);
- var result = processor.restore(processor.escape(sourceCSS));
- assert.equal(result, targetCSS);
+ var restored = processor.restore(processor.escape(source));
+ assert.equal(restored, expected);
};
}
assert.isFalse(chunker.isEmpty());
},
'breaks at first brace': function (chunker) {
- assert.equal('a{color:red}', chunker.next());
+ assert.equal(chunker.next(), 'a{color:red}');
},
'breaks at second brace': function (chunker) {
- assert.equal('p{}', chunker.next());
+ assert.equal(chunker.next(), 'p{}');
}
},
'comments': {
assert.isFalse(chunker.isEmpty());
},
'breaks at first brace': function (chunker) {
- assert.equal('/* one */', chunker.next());
+ assert.equal(chunker.next(), '/* one */');
},
'breaks at second brace': function (chunker) {
- assert.equal(' /* two */', chunker.next());
+ assert.equal(chunker.next(), ' /* two */');
}
}
})
var index = 0;
new QuoteScanner(topic).each(function iterator() { index++; });
- assert.equal(0, index);
+ assert.equal(index, 0);
}
},
'one single quote': {
new QuoteScanner(topic).each(function iterator(match, tokensSoFar, nextStart) {
index++;
- assert.equal('\'one quote\'', match);
- assert.deepEqual(['text with '], tokensSoFar);
- assert.equal(10, nextStart);
+ assert.equal(match, '\'one quote\'');
+ assert.deepEqual(tokensSoFar, ['text with ']);
+ assert.equal(nextStart, 10);
});
- assert.equal(1, index);
+ assert.equal(index, 1);
}
},
'one double quote': {
new QuoteScanner(topic).each(function iterator(match, tokensSoFar, nextStart) {
index++;
- assert.equal('"one quote"', match);
- assert.deepEqual(['text with '], tokensSoFar);
- assert.equal(10, nextStart);
+ assert.equal(match, '"one quote"');
+ assert.deepEqual(tokensSoFar, ['text with ']);
+ assert.equal(nextStart, 10);
});
- assert.equal(1, index);
+ assert.equal(index, 1);
}
},
'mixed quotes': {
new QuoteScanner(topic).each(function iterator(match, tokensSoFar, nextStart) {
index++;
- assert.equal('"one \'quote\'"', match);
- assert.deepEqual(['text with '], tokensSoFar);
- assert.equal(10, nextStart);
+ assert.equal(match, '"one \'quote\'"');
+ assert.deepEqual(tokensSoFar, ['text with ']);
+ assert.equal(nextStart, 10);
});
- assert.equal(1, index);
+ assert.equal(index, 1);
}
},
'escaped quotes': {
new QuoteScanner(topic).each(function iterator(match, tokensSoFar, nextStart) {
index++;
- assert.equal('"one \\"quote"', match);
- assert.deepEqual(['text with '], tokensSoFar);
- assert.equal(10, nextStart);
+ assert.equal(match, '"one \\"quote"');
+ assert.deepEqual(tokensSoFar, ['text with ']);
+ assert.equal(nextStart, 10);
});
- assert.equal(1, index);
+ assert.equal(index, 1);
}
},
'two quotes': {
index++;
if (index == 1) {
- assert.equal('"one \\"quote"', match);
- assert.deepEqual(['text with '], tokensSoFar);
- assert.equal(10, nextStart);
+ assert.equal(match, '"one \\"quote"');
+ assert.deepEqual(tokensSoFar, ['text with ']);
+ assert.equal(nextStart, 10);
} else {
- assert.equal('\'another one\'', match);
- assert.deepEqual(['text with ', ' and '], tokensSoFar);
- assert.equal(28, nextStart);
+ assert.equal(match, '\'another one\'');
+ assert.deepEqual(tokensSoFar, ['text with ', ' and ']);
+ assert.equal(nextStart, 28);
}
});
- assert.equal(2, index);
+ assert.equal(index, 2);
}
}
})