spec/js/numbers/currency.spec.js in twitter_cldr_js-2.4.0 vs spec/js/numbers/currency.spec.js in twitter_cldr_js-3.1.0

- old
+ new

@@ -1,16 +1,19 @@ // Copyright 2012 Twitter, Inc // http://www.apache.org/licenses/LICENSE-2.0 -var TwitterCldr = require('../../../lib/assets/javascripts/twitter_cldr/en.js'); +var TwitterCldr = require('../../../lib/assets/javascripts/twitter_cldr/core.js'); +var data = require('../../../lib/assets/javascripts/twitter_cldr/en.js'); describe("CurrencyFormatter", function() { - describe("#format", function() { - beforeEach(function() { - formatter = new TwitterCldr.CurrencyFormatter(); - }); + var formatter; + beforeEach(function() { + TwitterCldr.set_data(data); + formatter = new TwitterCldr.CurrencyFormatter(); + }); + describe("#format", function() { it("should use a dollar sign when no other currency symbol is given (and default to a precision of 2)", function() { expect(formatter.format(12)).toEqual("$12.00"); }); it("handles negative numbers", function() { @@ -38,16 +41,18 @@ it("should allow a precision of zero", function() { expect(formatter.format(12.3, {currency: "EUR", precision: 0})).toEqual("€12"); }); it("should use the cldr_symbol for the corresponding currency code if use_cldr_code is specified", function() { + var old_currencies = TwitterCldr.Currencies.currencies; TwitterCldr.Currencies.currencies = { "JPY": {symbol: "¥", cldr_symbol: "YEN", currency: "JPY", "name": "Japanese yen"} }; expect(formatter.format(12, {currency: "JPY", use_cldr_symbol: true})).toEqual("YEN12"); + TwitterCldr.Currencies.currencies = old_currencies; }); it("overrides the default precision", function() { expect(formatter.format(12, {precision: 3})).toEqual("$12.000"); }); }); -}); \ No newline at end of file +});