import { describe, expect, it } from "@jest/globals"; import { setupTestServerContext, setupTestServerHolder } from "../testHelpers/apolloTestServerHelpers"; import assert = require("node:assert"); import { addMockShuttleToRepository, addMockStopToRepository, addMockSystemToRepository } from "../testHelpers/repositorySetupHelpers"; describe("MutationResolvers", () => { const holder = setupTestServerHolder() const context = setupTestServerContext(); describe("scheduleNotification", () => { const query = ` mutation ScheduleNotification($input: NotificationInput!) { scheduleNotification(input: $input) { success message data { deviceId shuttleId stopId } } } ` it("adds a notification to the notification service", async () => { const system = await addMockSystemToRepository(context.repository); const shuttle = await addMockShuttleToRepository(context.repository, system.id); const stop = await addMockStopToRepository(context.repository, system.id); const notificationInput = { deviceId: "1", shuttleId: shuttle.id, stopId: stop.id, }; const response = await holder.testServer.executeOperation({ query, variables: { input: notificationInput, } }, { contextValue: context, }); assert(response.body.kind === "single"); expect(response.body.singleResult.errors).toBeUndefined(); const notificationResponse = response.body.singleResult.data?.scheduleNotification as any; expect(notificationResponse?.success).toBe(true); expect(notificationResponse?.notification).toStrictEqual(notificationInput); }); it("fails if the shuttle ID doesn't exist", async () => { const system = await addMockSystemToRepository(context.repository); const stop = await addMockStopToRepository(context.repository, system.id); const notificationInput = { deviceId: "1", shuttleId: "1", stopId: stop.id, } const response = await holder.testServer.executeOperation({ query, variables: { input: notificationInput, } }, { contextValue: context }); assert(response.body.kind === "single"); expect(response.body.singleResult.errors).toBeUndefined(); const notificationResponse = response.body.singleResult.data?.scheduleNotification as any; expect(notificationResponse.success).toBe(false); }); it("fails if the stop ID doesn't exist", async () => { }); }); describe("cancelNotification", () => { it("removes the notification from the notification service", async () => { }); }); });