update query resolver tests to modify the context

This commit is contained in:
2025-04-07 12:37:08 -07:00
parent a830dadbee
commit c8ea822626

View File

@@ -1,6 +1,10 @@
import { describe, expect, it } from "@jest/globals"; import { describe, expect, it } from "@jest/globals";
import { generateMockPassioSystems } from "../testHelpers/mockDataGenerators"; import { generateMockPassioSystems } from "../testHelpers/mockDataGenerators";
import { setupTestServerContext, setupTestServerHolder } from "../testHelpers/apolloTestServerHelpers"; import {
buildSystemForTesting,
setupTestServerContext,
setupTestServerHolder
} from "../testHelpers/apolloTestServerHelpers";
import assert = require("node:assert"); import assert = require("node:assert");
import { addMockShuttleToRepository, addMockStopToRepository } from "../testHelpers/repositorySetupHelpers"; import { addMockShuttleToRepository, addMockStopToRepository } from "../testHelpers/repositorySetupHelpers";
import { ScheduledNotification } from "../../src/repositories/NotificationRepository"; import { ScheduledNotification } from "../../src/repositories/NotificationRepository";
@@ -50,6 +54,13 @@ describe("QueryResolvers", () => {
`; `;
it("returns a system for an ID from the repository", async () => { it("returns a system for an ID from the repository", async () => {
context.systems = [
buildSystemForTesting(),
buildSystemForTesting(),
];
context.findSystemById = (_: string) => context.systems[1];
context.systems[1].id = "test-id";
const systems = context.systems; const systems = context.systems;
const systemToGet = systems[1]; const systemToGet = systems[1];
@@ -69,6 +80,8 @@ describe("QueryResolvers", () => {
}); });
it("returns null if there is no system", async () => { it("returns null if there is no system", async () => {
context.findSystemById = (_: string) => null;
const response = await holder.testServer.executeOperation({ const response = await holder.testServer.executeOperation({
query, query,
variables: { variables: {