mirror of
https://github.com/iv-org/invidious
synced 2024-11-27 13:33:28 +01:00
i18n: use spectator for i18next plurals spec
This commit is contained in:
parent
1f2ccac8a0
commit
0120f44fd6
@ -42,7 +42,7 @@ shards:
|
|||||||
|
|
||||||
spectator:
|
spectator:
|
||||||
git: https://github.com/icy-arctic-fox/spectator.git
|
git: https://github.com/icy-arctic-fox/spectator.git
|
||||||
version: 0.10.3
|
version: 0.10.4
|
||||||
|
|
||||||
sqlite3:
|
sqlite3:
|
||||||
git: https://github.com/crystal-lang/crystal-sqlite3.git
|
git: https://github.com/crystal-lang/crystal-sqlite3.git
|
||||||
|
@ -28,10 +28,11 @@ dependencies:
|
|||||||
athena-negotiation:
|
athena-negotiation:
|
||||||
github: athena-framework/negotiation
|
github: athena-framework/negotiation
|
||||||
version: ~> 0.1.1
|
version: ~> 0.1.1
|
||||||
|
|
||||||
development_dependencies:
|
development_dependencies:
|
||||||
spectator:
|
spectator:
|
||||||
github: icy-arctic-fox/spectator
|
github: icy-arctic-fox/spectator
|
||||||
version: ~> 0.10.3
|
version: ~> 0.10.4
|
||||||
|
|
||||||
crystal: ">= 1.0.0, < 2.0.0"
|
crystal: ">= 1.0.0, < 2.0.0"
|
||||||
|
|
||||||
|
@ -1,7 +1,14 @@
|
|||||||
require "spec"
|
require "spectator"
|
||||||
require "../src/invidious/helpers/i18next.cr"
|
require "../src/invidious/helpers/i18next.cr"
|
||||||
|
|
||||||
resolver = I18next::Plurals::RESOLVER
|
Spectator.configure do |config|
|
||||||
|
config.fail_blank
|
||||||
|
config.randomize
|
||||||
|
end
|
||||||
|
|
||||||
|
def resolver
|
||||||
|
I18next::Plurals::RESOLVER
|
||||||
|
end
|
||||||
|
|
||||||
FORM_TESTS = {
|
FORM_TESTS = {
|
||||||
"ach" => I18next::Plurals::PluralForms::Single_gt_one,
|
"ach" => I18next::Plurals::PluralForms::Single_gt_one,
|
||||||
@ -30,7 +37,6 @@ FORM_TESTS = {
|
|||||||
"su" => I18next::Plurals::PluralForms::None,
|
"su" => I18next::Plurals::PluralForms::None,
|
||||||
"sk" => I18next::Plurals::PluralForms::Special_Czech_Slovak,
|
"sk" => I18next::Plurals::PluralForms::Special_Czech_Slovak,
|
||||||
"sl" => I18next::Plurals::PluralForms::Special_Slovenian,
|
"sl" => I18next::Plurals::PluralForms::Special_Slovenian,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SUFFIX_TESTS = {
|
SUFFIX_TESTS = {
|
||||||
@ -187,20 +193,20 @@ SUFFIX_TESTS = {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
describe "i18next_Plural_Resolver" do
|
Spectator.describe "i18next_Plural_Resolver" do
|
||||||
describe "get_plural_form" do
|
describe "get_plural_form" do
|
||||||
FORM_TESTS.each do |locale, form|
|
sample FORM_TESTS do |locale, form|
|
||||||
it "returns the right plural form for locale '#{locale}'" do
|
it "returns the right plural form for locale '#{locale}'" do
|
||||||
resolver.get_plural_form(locale).should eq(form)
|
expect(resolver.get_plural_form(locale)).to eq(form)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "get_suffix" do
|
describe "get_suffix" do
|
||||||
SUFFIX_TESTS.each do |locale, data|
|
sample SUFFIX_TESTS do |locale, tests|
|
||||||
it "returns the right suffix for locale '#{locale}'" do
|
it "returns the right suffix for locale '#{locale}'" do
|
||||||
data.each do |d|
|
tests.each do |d|
|
||||||
resolver.get_suffix(locale, d[:num]).should eq(d[:suffix])
|
expect(resolver.get_suffix(locale, d[:num])).to eq(d[:suffix])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user