Fix: Serialization does not handle non-enumerable properties in Node versions < 5.x (#677)

This commit is contained in:
Mirko Jotic
2018-07-03 15:08:17 -04:00
committed by Spencer
parent 40f43838dd
commit d26c91c840
2 changed files with 23 additions and 1 deletions

View File

@ -39,6 +39,24 @@ describe('JSON serializer', function () {
ser.serialize(thing);
}).to.throwError();
});
it('utilizes replacer or spaces if passed', function () {
sinon.spy(JSON, 'stringify');
var ser = makeSerializer();
var thing = { name: 'thing' };
ser.serialize(thing, null, 2);
expect(JSON.stringify.withArgs(thing, null, 2).calledOnce).to.be(true);
JSON.stringify.restore();
});
it('should call JSON.stringify with value only', function () {
sinon.spy(JSON, 'stringify');
var ser = makeSerializer();
var thing = { name: 'thing' };
ser.serialize(thing);
expect(JSON.stringify.withArgs(thing).calledOnce).to.be(true);
JSON.stringify.restore();
});
});
describe('#deserialize', function () {