-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.test.js
86 lines (75 loc) · 2.33 KB
/
index.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
const Code = require('code') // assertion library
const Lab = require('lab')
const lab = exports.lab = Lab.script()
const cssRazor = require('./index').default
const spawn = require('child_process').spawn
// Test output
const testResults = require('./test/results.js')
lab.experiment('css-razor', () => {
lab.test('returns promise with used CSS based on input HTML & CSS', (done) => {
cssRazor({
html: ['test/input/index.html'],
css: ['test/input/index.css'],
outputFile: 'test/output/index.css'
}).then((data) => {
Code.expect(data.css.split('\r').join('')).to.equal(testResults.simpleCss)
done()
})
})
lab.test('calls callback with used CSS based on input HTML & CSS', (done) => {
cssRazor({
html: ['test/input/index.html'],
css: ['test/input/index.css'],
outputFile: 'test/output/index.css'
}, function (err, data) {
if (err) {
console.error(err)
}
Code.expect(data.css.split('\r').join('')).to.equal(testResults.simpleCss)
done()
})
})
lab.test('returns promise with used CSS based on more complex input HTML & CSS', (done) => {
cssRazor({
html: ['test/input/tachyons.html'],
css: ['test/input/tachyons.min.css'],
outputFile: 'test/output/tachyons.css'
}).then((data) => {
Code.expect(data.css.split('\r').join('')).to.equal(testResults.complexCss)
done()
})
})
lab.test('calls callback with used CSS based on more complex input webpage & CSS', (done) => {
cssRazor({
webpages: ['http://blog.timscanlin.net/'],
css: ['test/input/tachyons.min.css'],
outputFile: 'test/output/tachyons.css'
}, function (err, data) {
if (err) {
console.error(err)
}
Code.expect(data.css.split('\r').join('')).to.equal(testResults.complexHttpCss)
done()
})
})
lab.test('CLI returns used CSS based on input HTML & CSS', (done) => {
const cli = spawn('node', [
'./cli.js',
'test/input/index.html',
'test/input/index.css'
])
cli.stdout.on('data', (data) => {
Code.expect(data.toString().split('\r').join('')).to.equal(testResults.simpleCss)
})
cli.on('close', (code) => {
Code.expect(code).to.equal(0)
done()
})
})
// empty input
// no files
// multiple files
// raw
// postcss
// set output file
})