diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/Language/GraphQL/ClassSpec.hs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/Language/GraphQL/ClassSpec.hs b/tests/Language/GraphQL/ClassSpec.hs index 087abd0..a5ed41f 100644 --- a/tests/Language/GraphQL/ClassSpec.hs +++ b/tests/Language/GraphQL/ClassSpec.hs @@ -8,6 +8,8 @@ module Language.GraphQL.ClassSpec ) where import Data.Text (Text) +import Data.Time (UTCTime(..)) +import Data.Time.Calendar.OrdinalDate (fromOrdinalDate) import qualified Language.GraphQL.Type as Type import Language.GraphQL.Class (FromGraphQL(..), ToGraphQL(..)) import Test.Hspec (Spec, describe, it, shouldBe) @@ -30,6 +32,15 @@ spec = do it "converts singleton lists" $ toGraphQL [True] `shouldBe` Type.List [Type.Boolean True] + it "converts UTCTime" $ + let given = UTCTime + { utctDay = fromOrdinalDate 2023 5 + , utctDayTime = 90 + } + actual = toGraphQL given + expected = Type.String "2023-01-05T00:01:30Z" + in actual `shouldBe` expected + describe "FromGraphQL" $ do it "converts integers" $ fromGraphQL (Type.Int 5) `shouldBe` Just (5 :: Int) @@ -45,3 +56,12 @@ spec = do it "converts singleton lists" $ fromGraphQL (Type.List [Type.Boolean True]) `shouldBe` Just [True] + + it "converts UTCTime" $ + let given = Type.String "2023-01-05T00:01:30Z" + expected = Just $ UTCTime + { utctDay = fromOrdinalDate 2023 5 + , utctDayTime = 90 + } + actual = fromGraphQL given + in actual `shouldBe` expected |
