-
-
Notifications
You must be signed in to change notification settings - Fork 750
Expand file tree
/
Copy pathoutput_test.js
More file actions
69 lines (54 loc) · 1.57 KB
/
output_test.js
File metadata and controls
69 lines (54 loc) · 1.57 KB
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
let chai
let expect
import('chai').then(_chai => {
chai = _chai
expect = chai.expect
chai.use(sinonChai)
})
const sinonChai = require('sinon-chai')
const sinon = require('sinon')
const originalOutput = require('../../lib/output')
let output
describe('Output', () => {
beforeEach(() => {
sinon.spy(console, 'log')
output = originalOutput
})
it('should allow the output level to be set', () => {
const expectedLevel = 2
output.level(expectedLevel)
expect(output.level()).to.equal(expectedLevel)
})
it('should allow the process to be set', () => {
const expectedProcess = {
profile: 'firefox',
}
output.process(expectedProcess)
// The new format includes "Worker" prefix and cyan color
expect(output.process()).to.contain('[Worker')
expect(output.process()).to.contain(']')
})
it('should allow debug messages when output level >= 2', () => {
const debugMsg = 'Dear Henrietta'
output.level(0)
output.debug(debugMsg)
expect(console.log).not.to.be.called
output.level(1)
output.debug(debugMsg)
expect(console.log).not.to.be.called
output.level(2)
output.debug(debugMsg)
expect(console.log).to.have.been.called
output.level(3)
output.debug(debugMsg)
expect(console.log).to.have.been.calledTwice
})
it('should not throwing error when using non predefined system color for say function', () => {
const debugMsg = 'Dear Henrietta'
output.say(debugMsg, 'orange')
expect(console.log).to.have.been.called
})
afterEach(() => {
console.log.restore()
})
})