2019-07-22 05:50:00 +02:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
2019-09-06 07:48:01 +02:00
|
|
|
{-# LANGUAGE QuasiQuotes #-}
|
2019-07-22 05:50:00 +02:00
|
|
|
module Language.GraphQL.ParserSpec
|
|
|
|
( spec
|
|
|
|
) where
|
|
|
|
|
|
|
|
import Language.GraphQL.Parser (document)
|
2019-09-27 10:50:38 +02:00
|
|
|
import Test.Hspec (Spec, describe, it)
|
|
|
|
import Test.Hspec.Megaparsec (shouldSucceedOn)
|
2019-07-22 05:50:00 +02:00
|
|
|
import Text.Megaparsec (parse)
|
2019-09-06 07:48:01 +02:00
|
|
|
import Text.RawString.QQ (r)
|
2019-07-22 05:50:00 +02:00
|
|
|
|
|
|
|
spec :: Spec
|
2019-09-06 07:48:01 +02:00
|
|
|
spec = describe "Parser" $ do
|
2019-07-22 05:50:00 +02:00
|
|
|
it "accepts BOM header" $
|
2019-09-27 10:50:38 +02:00
|
|
|
parse document "" `shouldSucceedOn` "\xfeff{foo}"
|
2019-09-06 07:48:01 +02:00
|
|
|
|
|
|
|
it "accepts block strings as argument" $
|
2019-09-27 10:50:38 +02:00
|
|
|
parse document "" `shouldSucceedOn` [r|{
|
2019-09-06 07:48:01 +02:00
|
|
|
hello(text: """Argument""")
|
2019-09-27 10:50:38 +02:00
|
|
|
}|]
|
2019-09-06 07:48:01 +02:00
|
|
|
|
|
|
|
it "accepts strings as argument" $
|
2019-09-27 10:50:38 +02:00
|
|
|
parse document "" `shouldSucceedOn` [r|{
|
2019-09-06 07:48:01 +02:00
|
|
|
hello(text: "Argument")
|
2019-09-27 10:50:38 +02:00
|
|
|
}|]
|