shard-athena-negotiation/spec/accept_language_spec.cr
2020-12-24 00:48:48 -05:00

31 lines
788 B
Crystal

require "./spec_helper"
struct AcceptLanguageTest < ASPEC::TestCase
@[DataProvider("accept_value_data_provider")]
def test_accept_value(header : String?, expected : String?) : Nil
ANG::AcceptLanguage.new(header).accept_value.should eq expected
end
def accept_value_data_provider : Tuple
{
{"en;q=0.7", "en"},
{"en-GB;q=0.8", "en-gb"},
{"da", "da"},
{"en-gb;q=0.8", "en-gb"},
{"es;q=0.7", "es"},
{"fr ; q= 0.1", "fr"},
}
end
@[DataProvider("header_data_provider")]
def test_get_value(header : String?, expected : String?) : Nil
ANG::AcceptLanguage.new(header).header.should eq expected
end
def header_data_provider : Tuple
{
{"en;q=0.7", "en;q=0.7"},
{"en-GB;q=0.8", "en-GB;q=0.8"},
}
end
end