Try all extension parsers

This commit is contained in:
2020-01-28 11:08:28 +01:00
parent a6bd2370b6
commit e8b82122c6
6 changed files with 48 additions and 37 deletions

View File

@ -88,9 +88,12 @@ spec = describe "Lexer" $ do
it "lexes ampersand" $
parse amp "" "&" `shouldParse` "&"
it "lexes schema extensions" $
parse (extend "schema") "" `shouldSucceedOn` "extend schema"
parseExtend "schema" `shouldSucceedOn` "extend schema"
it "fails if the given token doesn't match" $
parse (extend "schema") "" `shouldFailOn` "extend shema"
parseExtend "schema" `shouldFailOn` "extend shema"
parseExtend :: Text -> (Text -> Either (ParseErrorBundle Text Void) ())
parseExtend extension = parse (extend extension "" $ pure $ pure ()) ""
runBetween :: (Parser () -> Parser ()) -> Text -> Either (ParseErrorBundle Text Void) ()
runBetween parser = parse (parser $ pure ()) ""

View File

@ -135,3 +135,10 @@ spec = describe "Parser" $ do
$ OperationTypeDefinition Query "Query" :| []
query = [r|extend schema @newDirective { query: Query }|]
in parse document "" query `shouldParse` (testSchemaExtension :| [])
it "parses an object extension" $
parse document "" `shouldSucceedOn` [r|
extend type Story {
isHiddenLocally: Boolean
}
|]