| 1 | require 'lafcadio/test' |
|---|
| 2 | require 'lafcadio/util' |
|---|
| 3 | |
|---|
| 4 | class TestEnglish < LafcadioTestCase |
|---|
| 5 | def testCamelCaseToEnglish |
|---|
| 6 | assert_equal "product category", |
|---|
| 7 | English.camel_case_to_english("productCategory") |
|---|
| 8 | assert_equal "product category", |
|---|
| 9 | English.camel_case_to_english("ProductCategory") |
|---|
| 10 | assert_equal 'catalog order', |
|---|
| 11 | English.camel_case_to_english('catalogOrder') |
|---|
| 12 | assert_equal 'product', English.camel_case_to_english('product') |
|---|
| 13 | end |
|---|
| 14 | |
|---|
| 15 | def testSentence |
|---|
| 16 | sentence = English.sentence("There %is currently %num %nam", |
|---|
| 17 | "product category", 0) |
|---|
| 18 | assert_equal("There are currently 0 product categories", sentence) |
|---|
| 19 | sentence2 = English.sentence("Add %a %nam", "sku") |
|---|
| 20 | assert_equal("Add a sku", sentence2) |
|---|
| 21 | sentence3 = English.sentence("Add %a %nam", "invoice") |
|---|
| 22 | assert_equal("Add an invoice", sentence3) |
|---|
| 23 | sentence4 = English.sentence("Add %a %nam", 'user') |
|---|
| 24 | assert_equal 'Add a user', sentence4 |
|---|
| 25 | end |
|---|
| 26 | |
|---|
| 27 | def testPlural |
|---|
| 28 | assert_equal "product categories", English.plural("product category") |
|---|
| 29 | assert_equal "products", English.plural("product") |
|---|
| 30 | assert_equal 'addresses', English.plural('address') |
|---|
| 31 | assert_equal 'taxes', English.plural('tax') |
|---|
| 32 | end |
|---|
| 33 | |
|---|
| 34 | def testProperNoun |
|---|
| 35 | assert_equal "Albania", English.proper_noun("albania") |
|---|
| 36 | assert_equal "Bosnia and Herzegovina", |
|---|
| 37 | English.proper_noun("bosnia and herzegovina") |
|---|
| 38 | assert_equal "Faroe Islands", English.proper_noun("faroe islands") |
|---|
| 39 | assert_equal "Macedonia, the Former Yugoslav Republic of", |
|---|
| 40 | English.proper_noun("macedonia, the former yugoslav republic of") |
|---|
| 41 | assert_equal "Virgin Islands, U.S.", |
|---|
| 42 | English.proper_noun("virgin islands, u.s.") |
|---|
| 43 | end |
|---|
| 44 | |
|---|
| 45 | def testStartsWithVowelSound |
|---|
| 46 | assert English.starts_with_vowel_sound('order') |
|---|
| 47 | assert !English.starts_with_vowel_sound('catalogOrder') |
|---|
| 48 | assert !English.starts_with_vowel_sound('user') |
|---|
| 49 | end |
|---|
| 50 | |
|---|
| 51 | def testSingular |
|---|
| 52 | assert_equal 'tree', English.singular('trees') |
|---|
| 53 | assert_equal 'fairy', English.singular('fairies') |
|---|
| 54 | assert_equal 'address', English.singular('addresses') |
|---|
| 55 | end |
|---|
| 56 | end |
|---|