Skip to content

Commit

Permalink
fix: empty Symbol() returns Symbol(undefined) (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
flaambe authored Jan 21, 2021
1 parent 20087b8 commit d78096a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/symbol.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default function inspectSymbol(value) {
if ('description' in Symbol.prototype) {
return `Symbol(${value.description})`
return value.description ? `Symbol(${value.description})` : "'Symbol()'"
}
return value.toString()
}
5 changes: 5 additions & 0 deletions test/symbols.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import inspect from '../index'
import { expect } from 'chai'
describe('symbols', () => {
/* eslint-disable */
it('returns Symbol() for empty Symbol', () => {
expect(inspect(Symbol())).to.equal("'Symbol()'")
})

it('returns string wrapped in quotes', () => {
expect(inspect('abc')).to.equal("'abc'")
})
Expand Down

0 comments on commit d78096a

Please sign in to comment.