summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2021-02-04 08:12:12 +0100
committerEugen Wissner <belka@caraus.de>2021-02-04 08:12:12 +0100
commitb27da54bf4d4c75447c1cad4329c2b28ae2c6c82 (patch)
tree4dab919f43789d7daba1660b20603705e3620d20 /tests
parenta034f2ce4d6603b030e653b4a4a2c46098ce8880 (diff)
downloadgraphql-b27da54bf4d4c75447c1cad4329c2b28ae2c6c82.tar.gz
Provide custom Show instances for AST values
Diffstat (limited to 'tests')
-rw-r--r--tests/Language/GraphQL/AST/DocumentSpec.hs20
-rw-r--r--tests/Language/GraphQL/ValidateSpec.hs2
2 files changed, 21 insertions, 1 deletions
diff --git a/tests/Language/GraphQL/AST/DocumentSpec.hs b/tests/Language/GraphQL/AST/DocumentSpec.hs
new file mode 100644
index 0000000..ca13e17
--- /dev/null
+++ b/tests/Language/GraphQL/AST/DocumentSpec.hs
@@ -0,0 +1,20 @@
+{-# LANGUAGE DuplicateRecordFields #-}
+{-# LANGUAGE OverloadedStrings #-}
+module Language.GraphQL.AST.DocumentSpec
+ ( spec
+ ) where
+
+import Language.GraphQL.AST.Document
+import Test.Hspec (Spec, describe, it, shouldBe)
+
+spec :: Spec
+spec = do
+ describe "Document" $ do
+ it "shows objects" $
+ let zero = Location 0 0
+ object = ConstObject
+ [ ObjectField "field1" (Node (ConstFloat 1.2) zero) zero
+ , ObjectField "field2" (Node ConstNull zero) zero
+ ]
+ expected = "{ field1: 1.2, field2: null }"
+ in show object `shouldBe` expected
diff --git a/tests/Language/GraphQL/ValidateSpec.hs b/tests/Language/GraphQL/ValidateSpec.hs
index 24b0ad0..b47149d 100644
--- a/tests/Language/GraphQL/ValidateSpec.hs
+++ b/tests/Language/GraphQL/ValidateSpec.hs
@@ -851,7 +851,7 @@ spec =
|]
expected = Error
{ message =
- "Value ConstInt 3 cannot be coerced to type \"Boolean\"."
+ "Value 3 cannot be coerced to type \"Boolean\"."
, locations = [AST.Location 4 48]
}
in validate queryString `shouldBe` [expected]