-
Notifications
You must be signed in to change notification settings - Fork 968
Expand file tree
/
Copy pathtest.node.js
More file actions
57 lines (52 loc) · 1.61 KB
/
test.node.js
File metadata and controls
57 lines (52 loc) · 1.61 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
/* eslint-env mocha */
const assert = require('assert');
const util = require('util');
const sinon = require('sinon');
const debug = require('./src/node');
const formatWithOptionsSpy = sinon.spy(util, 'formatWithOptions');
beforeEach(() => {
formatWithOptionsSpy.resetHistory();
});
describe('debug node', () => {
describe('formatting options', () => {
it('calls util.formatWithOptions', () => {
debug.enable('*');
const stdErrWriteStub = sinon.stub(process.stderr, 'write');
const log = debug('formatting options');
log('hello world');
assert(util.formatWithOptions.callCount === 1);
stdErrWriteStub.restore();
});
it('calls util.formatWithOptions with inspectOpts', () => {
debug.enable('*');
const options = {
hideDate: true,
colors: true,
depth: 10,
showHidden: true
};
Object.assign(debug.inspectOpts, options);
const stdErrWriteStub = sinon.stub(process.stderr, 'write');
const log = debug('format with inspectOpts');
log('hello world2');
assert.deepStrictEqual(util.formatWithOptions.getCall(0).args[0], options);
stdErrWriteStub.restore();
});
it('calls util.formatWithOptions with inspectOpts (STDOUT)', () => {
debug.enable('*');
const options = {
hideDate: true,
colors: true,
depth: 10,
showHidden: true,
useStdout: true
};
Object.assign(debug.inspectOpts, options);
const stdOutWriteStub = sinon.stub(process.stdout, 'write');
const log = debug('format with inspectOpts');
log('hello world2');
assert.deepStrictEqual(util.formatWithOptions.getCall(0).args[0], options);
stdOutWriteStub.restore();
});
});
});