]> Git — Sourcephile - gargantext.git/blob - src-test/Parsers/Date.hs
Merge branch 'master' into fromRFC3339
[gargantext.git] / src-test / Parsers / Date.hs
1 {-# LANGUAGE NoImplicitPrelude #-}
2
3 module Parsers.Date where
4
5 import Gargantext.Prelude
6
7 import Test.Hspec
8 import Test.QuickCheck
9 import Parsers.Types
10
11 import Data.Either (Either(..))
12 import Data.Time (ZonedTime(..))
13 import Data.Text (pack, Text)
14
15 import Text.Parsec.Error (ParseError)
16 import Duckling.Time.Types (toRFC3339)
17 import Gargantext.Parsers.Date (fromRFC3339)
18
19 fromRFC3339Inv :: Either ParseError ZonedTime -> Text
20 fromRFC3339Inv (Right z) = toRFC3339 z
21 fromRFC3339Inv (Left pe) = pack $ show pe
22
23 testFromRFC3339 :: IO ()
24 testFromRFC3339 = hspec $ do
25 describe "Test fromRFC3339: " $ do
26 it "is the inverse of Duckling's toRFC3339" $ property $
27 \x -> (fromRFC3339 . fromRFC3339Inv) x == (x :: Either ParseError ZonedTime)