summaryrefslogtreecommitdiff
path: root/tests/Language/GraphQL/AST/EncoderSpec.hs
blob: 47718d28eae69f3a8c5e7b291f0b06f1279383fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{-# LANGUAGE OverloadedStrings #-}
module Language.GraphQL.AST.EncoderSpec
    ( spec
    ) where

import Language.GraphQL.AST (Value(..))
import Language.GraphQL.AST.Encoder
import Test.Hspec ( Spec
                  , describe
                  , it
                  , shouldBe
                  )

spec :: Spec
spec = describe "value" $ do
    it "escapes \\" $
        value minified (String "\\") `shouldBe` "\"\\\\\""
    it "escapes quotes" $
        value minified (String "\"") `shouldBe` "\"\\\"\""
    it "escapes backspace" $
        value minified (String "a\bc") `shouldBe` "\"a\\bc\""
    it "escapes Unicode" $
        value minified (String "\0") `shouldBe` "\"\\u0000\""