This repository has been archived by the owner on Apr 6, 2018. It is now read-only.
/
test.js
70 lines (54 loc) · 2.06 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
'use strict';
var expect = require('chai').expect;
var fs = require('fs-extra');
var rework = require('rework');
var suit = require('../index');
describe('suit()', function () {
var expectedDefault = fs.readFileSync('test/fixtures/expected-default.css', 'utf-8').toString().trim();
var expectedCustom = fs.readFileSync('test/fixtures/expected-custom.css', 'utf-8').toString().trim();
var original = fs.readFileSync('test/fixtures/original.css', 'utf-8').toString().trim();
var browsers = [
'android >=4',
'ff >=20',
'ie >=8',
'safari >=6'
];
describe('.process()', function () {
it('throws an error when there is no input String', function () {
var processed = function () {
return suit().process();
};
expect(processed).to.throw(Error);
});
it('generates the expected output with default browser config', function () {
var processed = suit().process(original);
// for debugging
fs.outputFileSync('test/tmp/processed-default.css', processed);
expect(processed).to.equal(expectedDefault);
});
it('generates the expected output with custom browser config', function () {
var processed = suit(browsers).process(original);
// for debugging
fs.outputFileSync('test/tmp/processed-custom.css', processed);
expect(processed).to.equal(expectedCustom);
});
});
describe('.rework()', function () {
it('generates the expected output with default browser config', function () {
var processed = rework(original)
.use(suit().rework)
.toString();
// for debugging
fs.outputFileSync('test/tmp/processed-rework-default.css', processed);
expect(processed).to.equal(expectedDefault);
});
it('generates the expected output with custom browser config', function () {
var processed = rework(original)
.use(suit(browsers).rework)
.toString();
// for debugging
fs.outputFileSync('test/tmp/processed-rework-custom.css', processed);
expect(processed).to.equal(expectedCustom);
});
});
});