update test helpers to consolidate ServerContext creation into one method

This commit is contained in:
2025-02-04 10:56:00 -08:00
parent 814f2c6584
commit b918bf7a67
9 changed files with 63 additions and 41 deletions

View File

@@ -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();
});
});
});
});