forked from SpringRoll/SpringRoll
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDebugger.spec.js
42 lines (37 loc) · 1.52 KB
/
Debugger.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
import { Debugger } from './Debugger';
describe('Debugger', () => {
it('Should emit when the appropriate log level is assigned', () => {
expect(Debugger.log('general', 'test general')).to.be.true;
expect(Debugger.log('debug', 'test debug')).to.be.true;
expect(Debugger.log('info', 'test info')).to.be.true;
expect(Debugger.log('warn', 'test warn')).to.be.true;
expect(Debugger.log('error', 'test error')).to.be.true;
});
it('should not emit when the level is higher than the log level', () => {
Debugger.minLevel('error');
expect(Debugger.log('general', 'test general')).to.be.false;
expect(Debugger.log('debug', 'test debug')).to.be.false;
expect(Debugger.log('info', 'test info')).to.be.false;
expect(Debugger.log('warn', 'test warn')).to.be.false;
expect(Debugger.log('error', 'test error')).to.be.true;
});
it('assert should do nothing if true', () => {
Debugger.assert(true === true);
});
it('assert should throw if false ', done => {
try {
Debugger.assert(true !== true);
done(new Error());
} catch (err) {
done();
}
});
it('Nothing should run if global flag is set to false', () => {
Debugger.enable(false);
expect(Debugger.log('general', 'test general')).to.be.undefined;
expect(Debugger.log('debug', 'test debug')).to.be.undefined;
expect(Debugger.log('info', 'test info')).to.be.undefined;
expect(Debugger.log('warn', 'test warn')).to.be.undefined;
expect(Debugger.log('error', 'test error')).to.be.undefined;
});
});