Skip to content

Commit

Permalink
Fix for issue 516 (#517)
Browse files Browse the repository at this point in the history
* Fix for issue 516

#516

* Added unit test (#516)
  • Loading branch information
husticdf authored and mcollina committed Sep 18, 2018
1 parent 279a896 commit ce559ba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/levels.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function assertDefaultLevelFound (defaultLevel, customLevels, useOnlyCustomLevel
if (typeof defaultLevel === 'number') {
const values = [].concat(
Object.keys(customLevels || {}).map(key => customLevels[key]),
useOnlyCustomLevels ? [] : Object.keys(nums),
useOnlyCustomLevels ? [] : Object.keys(nums).map(level => +level),
Infinity
)
if (!values.includes(defaultLevel)) {
Expand Down
6 changes: 6 additions & 0 deletions test/levels.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,3 +381,9 @@ test('throws when creating a default value that does not exist in logger levels'
is(message, `default level:info must be included in custom levels`)
}
})

test('passes when creating a default value that exists in logger levels', async ({ is, throws }) => {
pino({
level: 30
})
})

0 comments on commit ce559ba

Please sign in to comment.