Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
456ada5
commit 31f7cd6
Showing
4 changed files
with
98 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
'use strict' | ||
const test = require('tape') | ||
const pino = require('../browser') | ||
|
||
test('set browser opts disabled to true', ({ end, same }) => { | ||
const instance = pino({ | ||
browser: { | ||
disabled: true, | ||
write (actual) { | ||
checkLogObjects(same, actual, []) | ||
} | ||
} | ||
}) | ||
instance.info('hello world') | ||
instance.error('this is an error') | ||
instance.fatal('this is fatal') | ||
|
||
end() | ||
}) | ||
|
||
test('set browser opts disabled to false', ({ end, same }) => { | ||
const expected = [ | ||
{ | ||
level: 30, | ||
msg: 'hello world' | ||
}, | ||
{ | ||
level: 50, | ||
msg: 'this is an error' | ||
}, | ||
{ | ||
level: 60, | ||
msg: 'this is fatal' | ||
} | ||
] | ||
const instance = pino({ | ||
browser: { | ||
disabled: false, | ||
write (actual) { | ||
checkLogObjects(same, actual, expected.shift()) | ||
} | ||
} | ||
}) | ||
instance.info('hello world') | ||
instance.error('this is an error') | ||
instance.fatal('this is fatal') | ||
|
||
end() | ||
}) | ||
|
||
test('disabled is not set in browser opts', ({ end, same }) => { | ||
const expected = [ | ||
{ | ||
level: 30, | ||
msg: 'hello world' | ||
}, | ||
{ | ||
level: 50, | ||
msg: 'this is an error' | ||
}, | ||
{ | ||
level: 60, | ||
msg: 'this is fatal' | ||
} | ||
] | ||
const instance = pino({ | ||
browser: { | ||
write (actual) { | ||
checkLogObjects(same, actual, expected.shift()) | ||
} | ||
} | ||
}) | ||
instance.info('hello world') | ||
instance.error('this is an error') | ||
instance.fatal('this is fatal') | ||
|
||
end() | ||
}) | ||
|
||
function checkLogObjects (same, actual, expected, is) { | ||
const actualCopy = Object.assign({}, actual) | ||
const expectedCopy = Object.assign({}, expected) | ||
delete actualCopy.time | ||
delete expectedCopy.time | ||
|
||
same(actualCopy, expectedCopy) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,6 +103,7 @@ pino({ | |
logEvent.messages; | ||
}, | ||
}, | ||
disabled: false | ||
}, | ||
}); | ||
|
||
|