summaryrefslogtreecommitdiff
path: root/vendor/gems/common_languages/test/usage_test.rb
blob: dc545f4857a67d6785691c76867c7be20d601540 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
require_relative 'test_helper'
require 'i18n'

class UsageTest < MiniTest::Test

  def setup
    CommonLanguages.reset
  end

  def test_available_codes_are_sorted
    I18n.available_locales = ['pt', 'en', :de, :es]
    assert_equal ['es', 'en', 'pt', 'de'], CommonLanguages.available_codes
  end

  def test_available
    I18n.available_locales = [:en]
    english = CommonLanguages::Language.new(CommonLanguages::DATA[2])
    assert_equal english, CommonLanguages.get(:en)
    assert_equal [english], CommonLanguages.available
  end

  def test_unique_codes
    assert_equal CommonLanguages::DATA.size, CommonLanguages::languages.size
  end

  #def test_data
  #  I18n.available_locales = [:en, :de, :pt]
  #  CommonLanguages.available.each do |language|
  #    p [language.code, language.name, language.english_name, language.rtl?]
  #  end
  #end

end