graphql/tests/Language/GraphQL/ParserSpec.hs

31 lines
831 B
Haskell
Raw Normal View History

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 Data.Either (isRight)
import Language.GraphQL.Parser (document)
import Test.Hspec ( Spec
, describe
, it
, shouldSatisfy
)
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" $
parse document "" "\xfeff{foo}" `shouldSatisfy` isRight
2019-09-06 07:48:01 +02:00
it "accepts block strings as argument" $
parse document "" [r|{
hello(text: """Argument""")
}|] `shouldSatisfy` isRight
it "accepts strings as argument" $
parse document "" [r|{
hello(text: "Argument")
}|] `shouldSatisfy` isRight