summaryrefslogtreecommitdiff
path: root/tests/Language
diff options
context:
space:
mode:
authorDmitrii Skurikhin <dmitrii.sk@gmail.com>2022-01-06 16:49:54 +0300
committerEugen Wissner <belka@caraus.de>2022-01-09 09:00:56 +0100
commit0c8edae90af9ca9033dc106756cf8ce29c08087b (patch)
treed69d80fccadfde2afe6906031363d976fcf11ec4 /tests/Language
parent73585dde85f9f0a5f88230768ae50cf4ea2c49b9 (diff)
downloadgraphql-0c8edae90af9ca9033dc106756cf8ce29c08087b.tar.gz
fix empty list argument parsing
Diffstat (limited to 'tests/Language')
-rw-r--r--tests/Language/GraphQL/AST/ParserSpec.hs82
1 files changed, 56 insertions, 26 deletions
diff --git a/tests/Language/GraphQL/AST/ParserSpec.hs b/tests/Language/GraphQL/AST/ParserSpec.hs
index 702beab..dbdc063 100644
--- a/tests/Language/GraphQL/AST/ParserSpec.hs
+++ b/tests/Language/GraphQL/AST/ParserSpec.hs
@@ -9,7 +9,7 @@ import Language.GraphQL.AST.Document
import qualified Language.GraphQL.AST.DirectiveLocation as DirLoc
import Language.GraphQL.AST.Parser
import Language.GraphQL.TH
-import Test.Hspec (Spec, describe, it)
+import Test.Hspec (Spec, describe, it, context)
import Test.Hspec.Megaparsec (shouldParse, shouldFailOn, shouldSucceedOn)
import Text.Megaparsec (parse)
@@ -18,33 +18,56 @@ spec = describe "Parser" $ do
it "accepts BOM header" $
parse document "" `shouldSucceedOn` "\xfeff{foo}"
- it "accepts block strings as argument" $
- parse document "" `shouldSucceedOn` [gql|{
- hello(text: """Argument""")
- }|]
+ context "Arguments" $ do
+ it "accepts block strings as argument" $
+ parse document "" `shouldSucceedOn` [gql|{
+ hello(text: """Argument""")
+ }|]
+
+ it "accepts strings as argument" $
+ parse document "" `shouldSucceedOn` [gql|{
+ hello(text: "Argument")
+ }|]
+
+ it "accepts int as argument" $
+ parse document "" `shouldSucceedOn` [gql|{
+ user(id: 4)
+ }|]
+
+ it "accepts boolean as argument" $
+ parse document "" `shouldSucceedOn` [gql|{
+ hello(flag: true) { field1 }
+ }|]
+
+ it "accepts float as argument" $
+ parse document "" `shouldSucceedOn` [gql|{
+ body(height: 172.5) { height }
+ }|]
+
+ it "accepts empty list as argument" $
+ parse document "" `shouldSucceedOn` [gql|{
+ query(list: []) { field1 }
+ }|]
+
+ it "accepts two required arguments" $
+ parse document "" `shouldSucceedOn` [gql|
+ mutation auth($username: String!, $password: String!){
+ test
+ }|]
+
+ it "accepts two string arguments" $
+ parse document "" `shouldSucceedOn` [gql|
+ mutation auth{
+ test(username: "username", password: "password")
+ }|]
+
+ it "accepts two block string arguments" $
+ parse document "" `shouldSucceedOn` [gql|
+ mutation auth{
+ test(username: """username""", password: """password""")
+ }|]
- it "accepts strings as argument" $
- parse document "" `shouldSucceedOn` [gql|{
- hello(text: "Argument")
- }|]
- it "accepts two required arguments" $
- parse document "" `shouldSucceedOn` [gql|
- mutation auth($username: String!, $password: String!){
- test
- }|]
-
- it "accepts two string arguments" $
- parse document "" `shouldSucceedOn` [gql|
- mutation auth{
- test(username: "username", password: "password")
- }|]
-
- it "accepts two block string arguments" $
- parse document "" `shouldSucceedOn` [gql|
- mutation auth{
- test(username: """username""", password: """password""")
- }|]
it "parses minimal schema definition" $
parse document "" `shouldSucceedOn` [gql|schema { query: Query }|]
@@ -202,6 +225,13 @@ spec = describe "Parser" $ do
}
|]
+ it "rejects empty selection set" $
+ parse document "" `shouldFailOn` [gql|
+ query {
+ innerField {}
+ }
+ |]
+
it "parses documents beginning with a comment" $
parse document "" `shouldSucceedOn` [gql|
"""