Sha256: 4600c38a9eecde361d7059043c87066157a3ab96416e7cac6e0a82e797689166

Contents?: true

Size: 1.69 KB

Versions: 17

Compression:

Stored size: 1.69 KB

Contents

# encoding: UTF-8

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

require 'spec_helper'

include TwitterCldr::Shared

describe PropertyNameAliases do
  let(:alias_class) { PropertyNameAliases }

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

    it 'returns nil if no alias can be found' do
      expect(alias_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(alias_class.long_alias_for('sc')).to eq('Script')
      expect(alias_class.long_alias_for('age')).to eq('Age')
      expect(alias_class.long_alias_for('uc')).to eq('Uppercase_Mapping')
    end

    it 'returns nil if no alias can be found' do
      expect(alias_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 = alias_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(alias_class.aliases_for('foo')).to eq([])
    end
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/twitter_cldr-4.4.5/spec/shared/property_name_aliases_spec.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/twitter_cldr-4.4.5/spec/shared/property_name_aliases_spec.rb
twitter_cldr-4.4.5 spec/shared/property_name_aliases_spec.rb
twitter_cldr-4.4.4 spec/shared/property_name_aliases_spec.rb
twitter_cldr-4.4.3 spec/shared/property_name_aliases_spec.rb
twitter_cldr-4.4.2 spec/shared/property_name_aliases_spec.rb
twitter_cldr-4.4.1 spec/shared/property_name_aliases_spec.rb
twitter_cldr-4.4.0 spec/shared/property_name_aliases_spec.rb
twitter_cldr-4.3.1 spec/shared/property_name_aliases_spec.rb
twitter_cldr-4.3.0 spec/shared/property_name_aliases_spec.rb
twitter_cldr-4.2.0 spec/shared/property_name_aliases_spec.rb
twitter_cldr-4.1.0 spec/shared/property_name_aliases_spec.rb
twitter_cldr-4.0.0 spec/shared/property_name_aliases_spec.rb
twitter_cldr-3.6.0 spec/shared/property_name_aliases_spec.rb
twitter_cldr-3.5.0 spec/shared/property_name_aliases_spec.rb
twitter_cldr-3.4.0 spec/shared/property_name_aliases_spec.rb
twitter_cldr-3.3.0 spec/shared/property_name_aliases_spec.rb