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'

Fixes #2856
  • Loading branch information
Xesenix committed May 27, 2018
1 parent c1526a1 commit 5763c5e
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 5763c5e

Please sign in to comment.