Unit: Fixed bug, stringified toJSON output
This commit is contained in:
parent
f6c7ec5d22
commit
dee30c749a
|
@ -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());
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue