Sha256: a2aef2cbc21ca8b3179cd9de266723278eed455f04e0e6596aa85e7e65ffb5cd

Contents?: true

Size: 1.68 KB

Versions: 27

Compression:

Stored size: 1.68 KB

Contents

# encoding: UTF-8

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

require 'spec_helper'

describe TwitterCldr::Shared::PropertyNameAliases do
  describe '#abbreviated_alias_for' do
    it 'finds the abbreviated alias for a long property name' do
      expect(described_class.abbreviated_alias_for('Script')).to eq('sc')
      expect(described_class.abbreviated_alias_for('Age')).to eq('age')
      expect(described_class.abbreviated_alias_for('Uppercase_Mapping')).to eq('uc')
    end

    it 'returns nil if no alias can be found' do
      expect(described_class.abbreviated_alias_for('foo')).to be_nil
    end
  end

  describe '#long_alias_for' do
    it 'finds the long alias for an abbreviated property name' do
      expect(described_class.long_alias_for('sc')).to eq('Script')
      expect(described_class.long_alias_for('age')).to eq('Age')
      expect(described_class.long_alias_for('uc')).to eq('Uppercase_Mapping')
    end

    it 'returns nil if no alias can be found' do
      expect(described_class.long_alias_for('foo')).to be_nil
    end
  end

  describe '#aliases_for' do
    examples = {
      'cjkRSUnicode' => %w(kRSUnicode Unicode_Radical_Stroke URS),
      'WSpace' => %w(White_Space space),
      'scf' => %w(Simple_Case_Folding sfc),
      'IDS' => %w(ID_Start)
    }

    examples.each_pair do |property_name, aliases|
      it "finds all the known aliases for the #{property_name} property name" do
        found = described_class.aliases_for(property_name)
        expect(found).to match_array(aliases)
      end
    end

    it 'returns an empty array if no aliases are found' do
      expect(described_class.aliases_for('foo')).to eq([])
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
twitter_cldr-6.0.1 spec/shared/property_name_aliases_spec.rb
twitter_cldr-6.0.0 spec/shared/property_name_aliases_spec.rb
twitter_cldr-5.4.0 spec/shared/property_name_aliases_spec.rb
twitter_cldr-5.3.0 spec/shared/property_name_aliases_spec.rb
twitter_cldr-5.2.0 spec/shared/property_name_aliases_spec.rb
twitter_cldr-5.1.0 spec/shared/property_name_aliases_spec.rb
twitter_cldr-5.0.0 spec/shared/property_name_aliases_spec.rb