Browse Source

Unit: Fixed bug, stringified toJSON output

patch-2
Braydon Fuller 10 years ago
parent
commit
dee30c749a
  1. 2
      lib/unit.js
  2. 2
      test/unit.js

2
lib/unit.js

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

2
test/unit.js

@ -124,7 +124,7 @@ describe('Unit', 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);
unit.toJSON().should.deep.equal(json);
});

Loading…
Cancel
Save