packages feed

fluent-1.0.0: test/IsolationSpec.hs

module IsolationSpec (spec) where

import Prelude

spec :: Spec
spec = do
    it "wraps a term reference" $
        translate
            "foo"
            (UseIsolating True)
            [fluent|
              -term = Term
              foo = a { -term } b
            |]
            `shouldBe` Right "a \8296Term\8297 b"
    it "wraps a message reference" $
        translate
            "foo"
            (UseIsolating True)
            [fluent|
              bar = Bar
              foo = a { bar } b
            |]
            `shouldBe` Right "a \8296Bar\8297 b"
    it "wraps a string literal" $
        translate "foo" (UseIsolating True) [fluent|foo = a { "Foo" } b|]
            `shouldBe` Right "a \8296Foo\8297 b"
    it "wraps a variable reference" $
        translate "foo" (UseIsolating True) ("arg", "Bar" :: Text) [fluent|foo = a { $arg } b|]
            `shouldBe` Right "a \8296Bar\8297 b"
    it "leaves a pattern of one element alone" $
        translate
            "foo"
            (UseIsolating True)
            [fluent|
              -term = Term
              foo = { -term }
            |]
            `shouldBe` Right "Term"
    it "is left out when the bundle turns it off" $
        translate
            "foo"
            (UseIsolating False)
            [fluent|
              -term = Term
              foo = a { -term } b
            |]
            `shouldBe` Right "a Term b"