Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add check for numbers #70

Merged
merged 3 commits into from Jun 18, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -65,7 +65,7 @@ module.exports = function prettyFactory (options) {
}

// Short-circuit for spec allowed primitive values.
if ([null, true, false].includes(log)) {
if ([null, true, false].includes(log) || Number.isFinite(log)) {
return `${log}\n`
}

Expand Down
14 changes: 14 additions & 0 deletions test/basic.test.js
Expand Up @@ -349,6 +349,20 @@ test('basic prettifier tests', (t) => {
t.end()
})

t.test('handles numbers', (t) => {
const pretty = prettyFactory()
let formatted = pretty(2)
t.is(formatted, '2\n')

formatted = pretty(-2)
t.is(formatted, '-2\n')

formatted = pretty(0.2)
t.is(formatted, '0.2\n')

mcollina marked this conversation as resolved.
Show resolved Hide resolved
t.end()
})

t.test('handles `undefined` input', (t) => {
t.plan(1)
const pretty = prettyFactory()
Expand Down