Unit: Fixed bug, stringified toJSON output

This commit is contained in:
Braydon Fuller 2014-12-12 20:02:18 -05:00
parent f6c7ec5d22
commit dee30c749a
2 changed files with 2 additions and 2 deletions

View File

@ -187,7 +187,7 @@ Unit.prototype.toObject = function toObject() {
}; };
Unit.prototype.toJSON = function toJSON() { Unit.prototype.toJSON = function toJSON() {
return this.toObject(); return JSON.stringify(this.toObject());
}; };
/** /**

View File

@ -124,7 +124,7 @@ describe('Unit', function() {
}); });
it('should input/output JSON', function() { it('should input/output JSON', function() {
var json = {amount:1.3, code:'BTC'}; var json = JSON.stringify({amount:1.3, code:'BTC'});
var unit = Unit.fromJSON(json); var unit = Unit.fromJSON(json);
unit.toJSON().should.deep.equal(json); unit.toJSON().should.deep.equal(json);
}); });