Provide custom Show instances for AST values

This commit is contained in:
2021-02-04 08:12:12 +01:00
parent a034f2ce4d
commit b27da54bf4
6 changed files with 89 additions and 27 deletions

View File

@ -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

View File

@ -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]