Sha256: bbeab3593cb900565cb69ffce8767bcd54da237553b43845272b3801842bbf4f

Contents?: true

Size: 1.25 KB

Versions: 27

Compression:

Stored size: 1.25 KB

Contents

# encoding: UTF-8

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

require 'spec_helper'

describe TwitterCldr::DataReaders::NumberDataReader do
  let(:data_reader) { described_class.new(:en) }

  describe '#format_number' do
    it 'works with options' do
      expect(data_reader.format_number(1000, precision: 2)).to eq('1,000.00')
    end

    it "works when options aren't specified" do
      expect(data_reader.format_number(1000)).to eq('1,000')
    end
  end

  describe "#pattern" do
    let(:symbols) { { nan: 'NaN', minus_sign: '<->' } } # unique locale-specific minus sign

    before(:each) do
      allow(TwitterCldr).to receive(:get_locale_resource).with(:en, :numbers) {
        {
          en: {
            numbers: {
              default_number_systems: {
                default: 'latn'
              },
              formats: { decimal: { latn: { default: "#,##0.###" } } },
              symbols: {
                latn: symbols
              }
            }
          }
        }
      }
    end

    it "returns pattern for a number" do
      expect(data_reader.pattern(2)).to eq("#,##0.###")
    end

    it "returns pattern for a negative number" do
      expect(data_reader.pattern(-2)).to eq("<->#,##0.###")
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
twitter_cldr-6.12.0 spec/data_readers/number_data_reader_spec.rb
twitter_cldr-6.11.5 spec/data_readers/number_data_reader_spec.rb
twitter_cldr-6.11.4 spec/data_readers/number_data_reader_spec.rb
twitter_cldr-6.11.3 spec/data_readers/number_data_reader_spec.rb
twitter_cldr-6.11.2 spec/data_readers/number_data_reader_spec.rb
twitter_cldr-6.11.1 spec/data_readers/number_data_reader_spec.rb
twitter_cldr-6.11.0 spec/data_readers/number_data_reader_spec.rb
twitter_cldr-6.10.0 spec/data_readers/number_data_reader_spec.rb
twitter_cldr-6.9.0 spec/data_readers/number_data_reader_spec.rb
twitter_cldr-6.8.0 spec/data_readers/number_data_reader_spec.rb
twitter_cldr-6.7.0 spec/data_readers/number_data_reader_spec.rb
twitter_cldr-6.6.2 spec/data_readers/number_data_reader_spec.rb
twitter_cldr-6.6.1 spec/data_readers/number_data_reader_spec.rb
twitter_cldr-6.6.0 spec/data_readers/number_data_reader_spec.rb
twitter_cldr-6.5.0 spec/data_readers/number_data_reader_spec.rb
twitter_cldr-6.4.0 spec/data_readers/number_data_reader_spec.rb
twitter_cldr-6.3.0 spec/data_readers/number_data_reader_spec.rb
twitter_cldr-6.2.0 spec/data_readers/number_data_reader_spec.rb
twitter_cldr-6.1.0 spec/data_readers/number_data_reader_spec.rb
twitter_cldr-6.0.2 spec/data_readers/number_data_reader_spec.rb