818
Du
dustymarkdown / files
dustymarkdown / node_modules / sqwish / tests / tests.js
1.5 KB
1var sink = require('../node_modules/sink-test/'), 2 start = sink.start, 3 sink = sink.sink, 4 sqwish = require('../src/'); 5 6sink('basic mode', function (test, ok) { 7 8 test('whitespace', 1, function () { 9 var input = ' \n body { color : red ; background : blue ; \r\n } ', 10 expected = 'body{color:red;background:blue}', 11 actual = sqwish.minify(input); 12 ok(actual == expected, 'all appropriate whitespace was removed'); 13 }); 14 15 test('long hex to short hex', 1, function () { 16 var input = 'p { color: #ffcc33; }', 17 expected = 'p{color:#fc3}', 18 actual = sqwish.minify(input); 19 ok(actual == expected, 'collapsed #ffcc33 to #fc3'); 20 }); 21 22 test('longhand values to shorthand values', 1, function () { 23 var input = 'p { margin: 0px 1px 0px 1px }', 24 expected = 'p{margin:0 1px}', 25 actual = sqwish.minify(input); 26 ok(actual == expected, 'collapsed 0px 1px 0px 1px to 0 1px'); 27 }); 28 29}); 30 31sink('strict mode', function (test, ok) { 32 test('combined rules', 1, function () { 33 var input = 'div { color: red; } div { background: orange; }', 34 expected = 'div{background:orange;color:red}', 35 actual = sqwish.minify(input, true); 36 ok(actual == expected, 'collapsed div into a single rule'); 37 }); 38 39 test('combine duplicate properties', 1, function () { 40 var input = 'div { color: red; } div { color: #ffcc88; }', 41 expected = 'div{color:#fc8}', 42 actual = sqwish.minify(input, true); 43 ok(actual == expected, 'collapsed duplicate into a single declaration'); 44 }); 45 46}); 47 48start();