Skip to content

Commit

Permalink
fix(common): stringify error on 'Cannot convert a Symbol value to a s…
Browse files Browse the repository at this point in the history
…tring' (#2990)

Fixes #2856
  • Loading branch information
Xesenix authored and johnjbarton committed May 28, 2018
1 parent c1526a1 commit 65b658a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions common/stringify.js
Expand Up @@ -14,6 +14,8 @@ var stringify = function stringify (obj, depth) {
}

switch (typeof obj) {
case 'symbol':
return obj.toString()
case 'string':
return "'" + obj + "'"
case 'undefined':
Expand Down
4 changes: 4 additions & 0 deletions test/client/stringify.spec.js
Expand Up @@ -4,6 +4,10 @@ var assert = require('assert')
var stringify = require('../../common/stringify')

describe('stringify', function () {
it('should serialize symbols', function () {
assert.deepEqual(stringify(Symbol.for('x')), 'Symbol(x)')
})

it('should serialize string', function () {
assert.deepEqual(stringify('aaa'), "'aaa'")
})
Expand Down

0 comments on commit 65b658a

Please sign in to comment.