Sha256: 8f15f6f88cd05b0d20c09ce9657edf614dc8ee050c56757cb9040774ab3d2f20

Contents?: true

Size: 1.09 KB

Versions: 4

Compression:

Stored size: 1.09 KB

Contents

// Copyright 2012 Twitter, Inc
// http://www.apache.org/licenses/LICENSE-2.0

var TwitterCldr = require('../../../lib/assets/javascripts/twitter_cldr/core.js');
var data = require('../../../lib/assets/javascripts/twitter_cldr/en.js');

describe("DecimalFormatter", function() {
  var formatter;
  beforeEach(function() {
    TwitterCldr.set_data(data);
    formatter = new TwitterCldr.DecimalFormatter();
  });

  describe("#format", function() {
    it("should format positive decimals correctly", function() {
      expect(formatter.format(12.1)).toEqual("12.1");
    });

    it("should format negative decimals correctly", function() {
      expect(formatter.format(-12.1)).toEqual("-12.1");
    });

    it("should respect the precision option", function() {
      expect(formatter.format(-12, {precision: 3})).toEqual("-12.000");
    });

    it("should allow a precision of zero", function() {
      expect(formatter.format(12.3, {precision: 0})).toEqual("12");
    });

    it("should format big numbers correctly", function() {
      expect(formatter.format(1234567)).toEqual("1,234,567");
    });
  });
});

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
twitter_cldr_js-3.3.0 spec/js/numbers/decimal.spec.js
twitter_cldr_js-3.2.0 spec/js/numbers/decimal.spec.js
twitter_cldr_js-3.1.1 spec/js/numbers/decimal.spec.js
twitter_cldr_js-3.1.0 spec/js/numbers/decimal.spec.js