Sha256: 5f6a6ec8f525b8ff5714c66f9c58b8d87c4fce18bb84f8851e612342497ec8ae
Contents?: true
Size: 1.76 KB
Versions: 1
Compression:
Stored size: 1.76 KB
Contents
var I18n = require("../../lib/i18n") , Translations = require("./translations") ; describe("Currency", function(){ var actual, expected; beforeEach(function() { I18n.reset(); I18n.translations = Translations(); }); it("formats currency with default settings", function(){ expect(I18n.toCurrency(100.99)).toEqual("$100.99"); expect(I18n.toCurrency(1000.99)).toEqual("$1,000.99"); }); it("formats currency with custom settings", function(){ I18n.translations.en.number = { currency: { format: { format: "%n %u", unit: "USD", delimiter: ".", separator: ",", precision: 2 } } }; expect(I18n.toCurrency(12)).toEqual("12,00 USD"); expect(I18n.toCurrency(123)).toEqual("123,00 USD"); expect(I18n.toCurrency(1234.56)).toEqual("1.234,56 USD"); }); it("formats currency with custom settings and partial overriding", function(){ I18n.translations.en.number = { currency: { format: { format: "%n %u", unit: "USD", delimiter: ".", separator: ",", precision: 2 } } }; expect(I18n.toCurrency(12, {precision: 0})).toEqual("12 USD"); expect(I18n.toCurrency(123, {unit: "bucks"})).toEqual("123,00 bucks"); }); it("formats currency with some custom options that should be merged with default options", function(){ expect(I18n.toCurrency(1234, {precision: 0})).toEqual("$1,234"); expect(I18n.toCurrency(1234, {unit: "º"})).toEqual("º1,234.00"); expect(I18n.toCurrency(1234, {separator: "-"})).toEqual("$1,234-00"); expect(I18n.toCurrency(1234, {delimiter: "-"})).toEqual("$1-234.00"); expect(I18n.toCurrency(1234, {format: "%u %n"})).toEqual("$ 1,234.00"); }); });
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
i18n-js-3.0.0.rc1 | spec/js/currency.spec.js |