Fix currency from integer.

This commit is contained in:
Arthur Britto
2013-04-26 15:38:04 -07:00
parent c82ff0575b
commit d37f0b9082
2 changed files with 7 additions and 1 deletions

View File

@@ -23,7 +23,7 @@ Currency.json_rewrite = function (j) {
Currency.from_json = function (j) {
if (j instanceof Currency) return j.clone();
else if ('string' === typeof j) return (new Currency()).parse_json(j);
else if ('string' === typeof j || 'number' === typeof j) return (new Currency()).parse_json(j);
else return new Currency(); // NaN
};

View File

@@ -12,6 +12,12 @@ var config = require('../src/js/config').load(require('./config'));
// XXX Add test cases that push XRP vs non-XRP behavior.
buster.testCase("Amount", {
"from_number" : {
"Number 1" : function () {
buster.assert.equals("1/1/rrrrrrrrrrrrrrrrrrrrBZbvji", Amount.from_number(1).to_text_full());
},
},
"UInt160" : {
"Parse 0" : function () {
buster.assert.equals(nbi(), UInt160.from_generic("0")._value);