summaryrefslogtreecommitdiff
path: root/tests/Language/GraphQL/AST
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2024-08-28 20:00:44 +0200
committerEugen Wissner <belka@caraus.de>2024-08-28 20:00:44 +0200
commit01b30a71da8b867269ad78d3091637f197714738 (patch)
tree3419312dbf12a5f5fc2649fc2a891ed062430b53 /tests/Language/GraphQL/AST
parentb40d8a7e1ef03e6ccbe990572add58cfaa6d8ed9 (diff)
downloadgraphql-01b30a71da8b867269ad78d3091637f197714738.tar.gz
Test directive definition decoder
Diffstat (limited to 'tests/Language/GraphQL/AST')
-rw-r--r--tests/Language/GraphQL/AST/EncoderSpec.hs24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/Language/GraphQL/AST/EncoderSpec.hs b/tests/Language/GraphQL/AST/EncoderSpec.hs
index 3fa6a02..37c6302 100644
--- a/tests/Language/GraphQL/AST/EncoderSpec.hs
+++ b/tests/Language/GraphQL/AST/EncoderSpec.hs
@@ -11,6 +11,7 @@ import Language.GraphQL.TH
import Test.Hspec (Spec, context, describe, it, shouldBe, shouldStartWith, shouldEndWith, shouldNotContain)
import Test.QuickCheck (choose, oneof, forAll)
import qualified Data.Text.Lazy as Text.Lazy
+import qualified Language.GraphQL.AST.DirectiveLocation as DirectiveLocation
spec :: Spec
spec = do
@@ -267,3 +268,26 @@ spec = do
|]
actual = typeSystemDefinition pretty definition'
in actual `shouldBe` expected
+
+ context "directive definition" $ do
+ it "encodes a directive definition" $ do
+ let definition' = Full.DirectiveDefinition mempty "example" mempty False
+ $ pure
+ $ DirectiveLocation.ExecutableDirectiveLocation DirectiveLocation.Field
+ expected = [gql|
+ @example() on
+ | FIELD
+ |]
+ actual = typeSystemDefinition pretty definition'
+ in actual `shouldBe` expected
+
+ it "encodes a repeatable directive definition" $ do
+ let definition' = Full.DirectiveDefinition mempty "example" mempty True
+ $ pure
+ $ DirectiveLocation.ExecutableDirectiveLocation DirectiveLocation.Field
+ expected = [gql|
+ @example() repeatable on
+ | FIELD
+ |]
+ actual = typeSystemDefinition pretty definition'
+ in actual `shouldBe` expected