Sha256: 832dfd92f9da7d25b8ca2b0b6d51295f28ba359129540decf2d922046388b686

Contents?: true

Size: 861 Bytes

Versions: 4

Compression:

Stored size: 861 Bytes

Contents

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

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

describe("FractionHelper", function() {
  describe("#apply", function() {
    it("test: formats a fraction", function() {
      var token = '###.##';
      expect(new TwitterCldr.NumberFormatter.FractionHelper(token).apply('45')).toEqual('.45');
    });

    it("test: pads zero digits on the right side", function() {
      var token = '###.0000#';
      expect(new TwitterCldr.NumberFormatter.FractionHelper(token).apply('45')).toEqual('.45000');
    });

    it("test: :precision option overrides format precision", function() {
      var token = '###.##';
      expect(new TwitterCldr.NumberFormatter.FractionHelper(token).apply('78901', {precision: 5})).toEqual('.78901');
    });
  });
});

Version data entries

4 entries across 4 versions & 1 rubygems

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