adds __typename tests to starwars testfile
This commit is contained in:
parent
cb73e9d53c
commit
624efbbb35
@ -45,7 +45,7 @@ test = testGroup "Star Wars Query Tests"
|
|||||||
$ object [ "data" .= object [
|
$ object [ "data" .= object [
|
||||||
"hero" .= object [
|
"hero" .= object [
|
||||||
"id" .= ("2001" :: Text)
|
"id" .= ("2001" :: Text)
|
||||||
, "name" .= ("R2-D2" :: Text)
|
, r2d2Name
|
||||||
, "friends" .= [
|
, "friends" .= [
|
||||||
object [lukeName]
|
object [lukeName]
|
||||||
, object [hanName]
|
, object [hanName]
|
||||||
@ -79,8 +79,8 @@ test = testGroup "Star Wars Query Tests"
|
|||||||
, "friends" .= [
|
, "friends" .= [
|
||||||
object [hanName]
|
object [hanName]
|
||||||
, object [leiaName]
|
, object [leiaName]
|
||||||
, object ["name" .= ("C-3PO" :: Text)]
|
, object [c3poName]
|
||||||
, object ["name" .= ("R2-D2" :: Text)]
|
, object [r2d2Name]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
, object [
|
, object [
|
||||||
@ -89,7 +89,7 @@ test = testGroup "Star Wars Query Tests"
|
|||||||
, "friends" .= [
|
, "friends" .= [
|
||||||
object [lukeName]
|
object [lukeName]
|
||||||
, object [leiaName]
|
, object [leiaName]
|
||||||
, object ["name" .= ("R2-D2" :: Text)]
|
, object [r2d2Name]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
, object [
|
, object [
|
||||||
@ -98,8 +98,8 @@ test = testGroup "Star Wars Query Tests"
|
|||||||
, "friends" .= [
|
, "friends" .= [
|
||||||
object [lukeName]
|
object [lukeName]
|
||||||
, object [hanName]
|
, object [hanName]
|
||||||
, object ["name" .= ("C-3PO" :: Text)]
|
, object [c3poName]
|
||||||
, object ["name" .= ("R2-D2" :: Text)]
|
, object [r2d2Name]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
@ -183,7 +183,7 @@ test = testGroup "Star Wars Query Tests"
|
|||||||
$ object [ "data" .= object [
|
$ object [ "data" .= object [
|
||||||
"hero" .= object [
|
"hero" .= object [
|
||||||
"id" .= ("2001" :: Text)
|
"id" .= ("2001" :: Text)
|
||||||
, "name" .= ("R2-D2" :: Text)
|
, r2d2Name
|
||||||
, "friends" .= [
|
, "friends" .= [
|
||||||
object ["friendName" .= ("Luke Skywalker" :: Text)]
|
object ["friendName" .= ("Luke Skywalker" :: Text)]
|
||||||
, object ["friendName" .= ("Han Solo" :: Text)]
|
, object ["friendName" .= ("Han Solo" :: Text)]
|
||||||
@ -241,11 +241,37 @@ test = testGroup "Star Wars Query Tests"
|
|||||||
, "leia" .= object [leiaName, alderaan]
|
, "leia" .= object [leiaName, alderaan]
|
||||||
]]
|
]]
|
||||||
]
|
]
|
||||||
|
, testGroup "__typename"
|
||||||
|
[ testCase "R2D2 is a Droid" . testQuery
|
||||||
|
[r| query CheckTypeOfR2 {
|
||||||
|
hero {
|
||||||
|
__typename
|
||||||
|
name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|]
|
||||||
|
$ object ["data" .= object [
|
||||||
|
"hero" .= ["__typename" .= ("Droid" :: Text), r2d2Name]
|
||||||
|
]]
|
||||||
|
, testCase "Luke is a human" . testQuery
|
||||||
|
[r| query CheckTypeOfLuke {
|
||||||
|
hero(episode: EMPIRE) {
|
||||||
|
__typename
|
||||||
|
name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|]
|
||||||
|
$ object ["data" .= object [
|
||||||
|
"hero" .= ["__typename" .= ("Human" :: Text), lukeName]
|
||||||
|
]]
|
||||||
|
]
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
lukeName = "name" .= ("Luke Skywalker" :: Text)
|
lukeName = "name" .= ("Luke Skywalker" :: Text)
|
||||||
leiaName = "name" .= ("Leia Organa" :: Text)
|
leiaName = "name" .= ("Leia Organa" :: Text)
|
||||||
hanName = "name" .= ("Han Solo" :: Text)
|
hanName = "name" .= ("Han Solo" :: Text)
|
||||||
|
r2d2Name = "name" .= ("R2-D2" :: Text)
|
||||||
|
c3poName = "name" .= ("C-3PO" :: Text)
|
||||||
tatooine = "homePlanet" .= ("Tatooine" :: Text)
|
tatooine = "homePlanet" .= ("Tatooine" :: Text)
|
||||||
alderaan = "homePlanet" .= ("Alderaan" :: Text)
|
alderaan = "homePlanet" .= ("Alderaan" :: Text)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user