This repository has been archived by the owner on Nov 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const result = () => { | ||
return ` | ||
Object { | ||
"data": Object { | ||
"abilityById": Object { | ||
"abilityDescription": "Fills a zone with powerful healing roots. Allies over it heal over 4 seconds. Each upgrade level increases HP healed", | ||
"abilityId": 85, | ||
"abilityName": "Healing Roots", | ||
"kingdom": "KRV", | ||
"levelCosts": Array [ | ||
130, | ||
130, | ||
130, | ||
], | ||
"numberOfLevels": 3, | ||
"totalAbilityCost": 390, | ||
"totalCostWithTowers": 1290, | ||
"towerId": 104, | ||
"towerImageUrl": "https://storage.googleapis.com/kingdom-rush-towers.appspot.com/krv-shaman4.png", | ||
"towerName": "orc shaman, 4", | ||
"towerType": "MAGE", | ||
}, | ||
}, | ||
"errors": undefined, | ||
"extensions": undefined, | ||
"http": Object { | ||
"headers": Headers { | ||
Symbol(map): Object {}, | ||
}, | ||
}, | ||
} | ||
` | ||
} | ||
|
||
export default result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { createConnection, getConnection } from "typeorm" | ||
import { buildSchema } from "type-graphql" | ||
import { AbilityResolver } from "../../src/resolvers/AbilityResolver" | ||
import { ApolloServer, gql } from "apollo-server" | ||
import { createTestClient } from "apollo-server-testing" | ||
import ABILITY_BY_ID_RESULT from "./__snapshots__/ABILITY_BY_ID" | ||
import { DocumentNode } from "graphql" | ||
|
||
beforeAll(async () => { | ||
await createConnection("test") | ||
}) | ||
|
||
afterAll(async () => { | ||
await getConnection("test").close() | ||
}) | ||
|
||
const executeTest = async (testQuery: DocumentNode, correctAnswer: string) => { | ||
const schema = await buildSchema({ resolvers: [AbilityResolver] }) | ||
const { query } = createTestClient(new ApolloServer({ schema })) | ||
|
||
const result = await query({ query: testQuery }) | ||
expect(result).toMatchInlineSnapshot(correctAnswer) | ||
} | ||
|
||
test("1. Be able to get ability data by its id", async () => { | ||
const testQuery = gql` | ||
{ | ||
abilityById(id: 85) { | ||
abilityDescription | ||
abilityId | ||
abilityName | ||
kingdom | ||
levelCosts | ||
numberOfLevels | ||
totalAbilityCost | ||
totalCostWithTowers | ||
towerId | ||
towerImageUrl | ||
towerName | ||
towerType | ||
} | ||
} | ||
` | ||
await executeTest(testQuery, ABILITY_BY_ID_RESULT()) | ||
}) |