fluent-1.0.0: test/ArgumentSpec.hs
module ArgumentSpec (spec) where
import Prelude
spec :: Spec
spec = do
it "is a text" $
translate "foo" ("arg", "Bar" :: Text) [fluent|foo = { $arg }|] `shouldBe` Right "Bar"
it "is a whole number" $
translate "foo" ("arg", 3 :: Int) [fluent|foo = { $arg }|] `shouldBe` Right "3"
it "is a number with a fraction" $
translate "foo" ("arg", 1.5 :: Scientific) [fluent|foo = { $arg }|] `shouldBe` Right "1.5"
it "is a value the caller has already made" $
translate "foo" ("arg", StringValue "Bar") [fluent|foo = { $arg }|] `shouldBe` Right "Bar"
it "counts the way the locale counts" $
translate
"foo"
("n", 1 :: Int)
[fluent|
foo = { $n ->
[one] one
*[other] other
}
|]
`shouldBe` Right "one"
it "is one of several" $
translate
"foo"
("name", "Ann" :: Text)
("count", 2 :: Int)
[fluent|foo = { $name } has { $count } messages|]
`shouldBe` Right "Ann has 2 messages"