2020-08-22 06:39:52 +02:00
|
|
|
{- This Source Code Form is subject to the terms of the Mozilla Public License,
|
|
|
|
v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
|
|
|
obtain one at https://mozilla.org/MPL/2.0/. -}
|
|
|
|
|
2019-07-23 06:04:33 +02:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
module Language.GraphQL.ErrorSpec
|
|
|
|
( spec
|
|
|
|
) where
|
|
|
|
|
2021-05-10 09:43:39 +02:00
|
|
|
import Data.List.NonEmpty (NonEmpty (..))
|
2019-07-23 06:04:33 +02:00
|
|
|
import Language.GraphQL.Error
|
2021-12-24 13:35:18 +01:00
|
|
|
import qualified Language.GraphQL.Type as Type
|
2021-05-10 09:43:39 +02:00
|
|
|
import Test.Hspec
|
|
|
|
( Spec
|
|
|
|
, describe
|
|
|
|
, it
|
|
|
|
, shouldBe
|
|
|
|
)
|
|
|
|
import Text.Megaparsec (PosState(..))
|
|
|
|
import Text.Megaparsec.Error (ParseError(..), ParseErrorBundle(..))
|
|
|
|
import Text.Megaparsec.Pos (SourcePos(..), mkPos)
|
2019-07-23 06:04:33 +02:00
|
|
|
|
|
|
|
spec :: Spec
|
2021-05-10 09:43:39 +02:00
|
|
|
spec = describe "parseError" $
|
|
|
|
it "generates response with a single error" $ do
|
|
|
|
let parseErrors = TrivialError 0 Nothing mempty :| []
|
|
|
|
posState = PosState
|
|
|
|
{ pstateInput = ""
|
|
|
|
, pstateOffset = 0
|
|
|
|
, pstateSourcePos = SourcePos "" (mkPos 1) (mkPos 1)
|
|
|
|
, pstateTabWidth = mkPos 1
|
|
|
|
, pstateLinePrefix = ""
|
|
|
|
}
|
2021-12-24 13:35:18 +01:00
|
|
|
Response Type.Null actual <-
|
2021-05-10 09:43:39 +02:00
|
|
|
parseError (ParseErrorBundle parseErrors posState)
|
|
|
|
length actual `shouldBe` 1
|