summaryrefslogtreecommitdiff
path: root/tests/Language/GraphQL/ParserSpec.hs
blob: 6425ea5d9cfc08961f51ae4a3fda0c375f91aeaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
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)
import Text.RawString.QQ (r)

spec :: Spec
spec = describe "Parser" $ do
    it "accepts BOM header" $
        parse document "" "\xfeff{foo}" `shouldSatisfy` isRight

    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