mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
update test helpers to consolidate ServerContext creation into one method
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
import { describe, expect, it } from "@jest/globals";
|
||||
import { generateMockSystems } from "../testHelpers/mockDataGenerators";
|
||||
import { setupTestServerContext } from "../testHelpers/apolloTestServerHelpers";
|
||||
import { setupTestServerContext, setupTestServerHolder } from "../testHelpers/apolloTestServerHelpers";
|
||||
import assert = require("node:assert");
|
||||
|
||||
// See Apollo documentation for integration test guide
|
||||
// https://www.apollographql.com/docs/apollo-server/testing/testing
|
||||
|
||||
describe("QueryResolvers", () => {
|
||||
const holder = setupTestServerHolder();
|
||||
const context = setupTestServerContext();
|
||||
|
||||
async function addMockSystems() {
|
||||
@@ -30,7 +31,7 @@ describe("QueryResolvers", () => {
|
||||
}
|
||||
`;
|
||||
|
||||
const response = await context.testServer.executeOperation({
|
||||
const response = await holder.testServer.executeOperation({
|
||||
query,
|
||||
}, {
|
||||
contextValue: {
|
||||
@@ -59,7 +60,7 @@ describe("QueryResolvers", () => {
|
||||
const systems = await addMockSystems();
|
||||
const systemToGet = systems[1];
|
||||
|
||||
const response = await context.testServer.executeOperation({
|
||||
const response = await holder.testServer.executeOperation({
|
||||
query,
|
||||
variables: {
|
||||
id: systemToGet.id,
|
||||
@@ -76,7 +77,7 @@ describe("QueryResolvers", () => {
|
||||
});
|
||||
|
||||
it("returns null if there is no system", async () => {
|
||||
const response = await context.testServer.executeOperation({
|
||||
const response = await holder.testServer.executeOperation({
|
||||
query,
|
||||
variables: {
|
||||
id: "nonexistent-id",
|
||||
@@ -92,4 +93,4 @@ describe("QueryResolvers", () => {
|
||||
expect(response.body.singleResult.data?.system).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user