Skip to content

Commit

Permalink
Also test newNodeLogContext
Browse files Browse the repository at this point in the history
  • Loading branch information
arv committed Mar 7, 2023
1 parent d529642 commit 1f07070
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/logger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,15 @@ test('Console logger calls JSON stringify on complex arguments', () => {
assert.deepEqual(jsonStringifySpy.getCall(0).args, [{b: 1}]);
assert.deepEqual(jsonStringifySpy.getCall(1).args, [[2, 3]]);
});

test('newNodeLogContext calls JSON stringify on complex arguments', () => {
const jsonStringifySpy = sinon.spy(JSON, 'stringify');
const mockDebug = mockConsoleMethod('debug');
const lc = newNodeLogContext('debug');
lc.debug?.('a', false, 123, {b: 1}, [2, 3]);
assert(mockDebug.calledOnce);
assert(mockDebug.calledWith('DBG', 'a', false, 123, '{"b":1}', '[2,3]'));
assert.equal(jsonStringifySpy.callCount, 2);
assert.deepEqual(jsonStringifySpy.getCall(0).args, [{b: 1}]);
assert.deepEqual(jsonStringifySpy.getCall(1).args, [[2, 3]]);
});

0 comments on commit 1f07070

Please sign in to comment.