options = options || {};
this.options = {
- advanced: options.advanced === undefined ? true : false,
- aggressiveMerging: undefined === options.aggressiveMerging ? true : false,
+ advanced: undefined === options.advanced ? true : !!options.advanced,
+ aggressiveMerging: undefined === options.aggressiveMerging ? true : !!options.aggressiveMerging,
benchmark: options.benchmark,
compatibility: new Compatibility(options.compatibility).toOptions(),
debug: options.debug,
inliner: options.inliner,
keepBreaks: options.keepBreaks || false,
keepSpecialComments: 'keepSpecialComments' in options ? options.keepSpecialComments : '*',
- processImport: undefined === options.processImport ? true : false,
- rebase: undefined === options.rebase ? true : false,
+ processImport: undefined === options.processImport ? true : !!options.processImport,
+ rebase: undefined === options.rebase ? true : !!options.rebase,
relativeTo: options.relativeTo,
root: options.root,
roundingPrecision: options.roundingPrecision,
var vows = require('vows');
var assert = require('assert');
+var path = require('path');
var CleanCSS = require('../index');
vows.describe('module tests').addBatch({
'should be processed correctly': function(minified) {
assert.equal('.one{color:red}', minified);
}
+ },
+ '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);
+ }
+ },
+ '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);
+ }
+ },
+ '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);
+ }
+ },
+ 'rebase': {
+ 'topic': new CleanCSS({ rebase: true, relativeTo: path.join(process.cwd(), 'test', 'data'), root: process.cwd() }).minify('div{background:url(./dummy.png)}'),
+ 'gets right output': function (minified) {
+ assert.include(minified, 'url(/test/data/dummy.png)');
+ }
+ }
}
}).export(module);