From bbcc2cecb8b255867577452f197caff9f4344f21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Oko=C5=84ski?= Date: Tue, 2 Aug 2016 14:22:28 +0200 Subject: [PATCH] Fix __typename related test cases --- tests/Test/StarWars/Data.hs | 4 ++++ tests/Test/StarWars/QueryTests.hs | 6 +++--- tests/Test/StarWars/Schema.hs | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/Test/StarWars/Data.hs b/tests/Test/StarWars/Data.hs index cec90ae..60e8f88 100644 --- a/tests/Test/StarWars/Data.hs +++ b/tests/Test/StarWars/Data.hs @@ -62,6 +62,10 @@ secretBackstory = error "secretBackstory is secret." luke :: Character luke = Right luke' +typename :: Character -> Text +typename (Left _) = "Droid" +typename (Right _) = "Human" + luke' :: Human luke' = Human { _humanChar = CharCommon diff --git a/tests/Test/StarWars/QueryTests.hs b/tests/Test/StarWars/QueryTests.hs index dee9929..12aa540 100644 --- a/tests/Test/StarWars/QueryTests.hs +++ b/tests/Test/StarWars/QueryTests.hs @@ -251,18 +251,18 @@ test = testGroup "Star Wars Query Tests" } |] $ object ["data" .= object [ - "hero" .= ["__typename" .= ("Droid" :: Text), r2d2Name] + "hero" .= object ["__typename" .= ("Droid" :: Text), r2d2Name] ]] , testCase "Luke is a human" . testQuery [r| query CheckTypeOfLuke { - hero(episode: EMPIRE) { + hero(episode: 5) { __typename name } } |] $ object ["data" .= object [ - "hero" .= ["__typename" .= ("Human" :: Text), lukeName] + "hero" .= object ["__typename" .= ("Human" :: Text), lukeName] ]] ] , testGroup "Errors in resolvers" diff --git a/tests/Test/StarWars/Schema.hs b/tests/Test/StarWars/Schema.hs index 9021bd0..e47d284 100644 --- a/tests/Test/StarWars/Schema.hs +++ b/tests/Test/StarWars/Schema.hs @@ -43,4 +43,5 @@ character char = , Schema.array "friends" $ character <$> getFriends char , Schema.enum "appearsIn" . traverse getEpisode $ appearsIn char , Schema.scalar "secretBackstory" $ secretBackstory char + , Schema.scalar "__typename" $ typename char ]