summaryrefslogtreecommitdiff
path: root/tests/Template.hs
blob: 9d1d39dd2e405ae033af3bd5cc8f2083fc168efb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module Template where

import qualified Data.Map as M

import Test.QuickCheck
import Data.Binary

import Text.Hakyll.Internal.Template

-- Test encoding/decoding of templates.
prop_template_encode_id :: Template -> Bool
prop_template_encode_id template = decode (encode template) == template

-- Check we get the same sting with empty substitutions.
prop_substitute_id string =
    regularSubstitute (fromString string) M.empty == string

-- substitute test case 1.
prop_substitute_case1 string1 string2 =
    finalSubstitute template context == string1 ++ " costs $" ++ string2 ++ "."
  where
    template = fromString "$product costs $$$price."
    context = M.fromList [ ("product", string1)
                         , ("price", string2)
                         ]