[FEATURE] add getter for a Currency's iso_code

This commit is contained in:
Geert Weening
2014-06-03 15:18:45 -07:00
parent 61586a4185
commit a71fc07ba5
2 changed files with 15 additions and 0 deletions

View File

@@ -346,6 +346,10 @@ Currency.prototype.to_human = function(opts) {
return this.to_json(opts); return this.to_json(opts);
}; };
Currency.prototype.get_iso = function() {
return this._iso_code;
};
exports.Currency = Currency; exports.Currency = Currency;
// vim:sw=2:sts=2:ts=8:et // vim:sw=2:sts=2:ts=8:et

View File

@@ -172,4 +172,15 @@ describe('Currency', function() {
assert.equal(Math.E, cur.get_interest_at(443845330 - 6291418827.05)); assert.equal(Math.E, cur.get_interest_at(443845330 - 6291418827.05));
}); });
}); });
describe('get_iso', function() {
it('should get "XRP" iso_code', function() {
assert.strictEqual('XRP', currency.from_json('XRP').get_iso());
});
it('should get iso_code', function() {
assert.strictEqual('USD', currency.from_json('USD - US Dollar').get_iso());
});
it('should get iso_code', function() {
assert.strictEqual('USD', currency.from_json('USD (0.5%pa)').get_iso());
});
});
}); });