-
-
Notifications
You must be signed in to change notification settings - Fork 400
/
Copy pathhtml.spec.js
53 lines (44 loc) · 1.46 KB
/
html.spec.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
const expect = require('expect.js')
const ChildProcess = require('child_process')
const fs = require('fs')
const path = require('path')
describe('CLI', () => {
describe('Formatter: html', () => {
it('should have stdout output with formatter html', (done) => {
const expected = fs
.readFileSync(path.resolve(__dirname, 'html.html'), 'utf8')
.replace(
/\{\{path\}\}/g,
path
.resolve(__dirname, 'example.html')
// TODO: we need to fix windows backslash
.replace('\\example', '/example')
)
const expectedParts = expected.split('\n')
ChildProcess.exec(
[
'node',
path.resolve(__dirname, '../../../bin/htmlhint'),
path.resolve(__dirname, 'example.html'),
'--format',
'html',
].join(' '),
(error, stdout, stderr) => {
expect(error).to.be.an('object')
expect(error.code).to.be.equal(1)
expect(stdout).not.to.equal('')
const stdoutParts = stdout.split('\n')
expect(stdoutParts.length).to.be.equal(expectedParts.length)
for (let i = 0; i < stdoutParts.length; i++) {
const lineIndicator = `[L${i + 1}]: `
expect(`${lineIndicator}${stdoutParts[i]}`).to.be.equal(
`${lineIndicator}${expectedParts[i]}`
)
}
expect(stderr).to.be.equal('')
done()
}
)
})
})
})