update test cases and implement add notification test

This commit is contained in:
2025-02-04 11:18:05 -08:00
parent 8ac71090e4
commit 0b9759aff1

View File

@@ -1,15 +1,61 @@
import { describe, it } from "@jest/globals"; import { describe, expect, it } from "@jest/globals";
import { setupTestServerHolder } from "../testHelpers/apolloTestServerHelpers"; import { setupTestServerContext, setupTestServerHolder } from "../testHelpers/apolloTestServerHelpers";
import assert = require("node:assert");
import {
addMockShuttleToRepository,
addMockStopToRepository,
addMockSystemToRepository
} from "../testHelpers/repositorySetupHelpers";
describe("MutationResolvers", () => { describe("MutationResolvers", () => {
const testServerHolder = setupTestServerHolder() const holder = setupTestServerHolder()
const context = setupTestServerContext();
describe("scheduleNotification", () => { describe("scheduleNotification", () => {
const query = `
mutation ScheduleNotification($input: NotificationInput!) {
scheduleNotification(input: $input) {
success
message
notification {
deviceId
shuttleId
stopId
}
}
}
`
it("adds a notification to the notification service", async () => { 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,
}
});
assert(response.body.kind === "single");
expect(response.body.singleResult.errors).toBeUndefined();
const returnedData = response.body.singleResult.data;
expect(returnedData?.success).toBe(true);
expect(returnedData?.notification).toStrictEqual(notificationInput);
});
it("fails if the shuttle ID doesn't exist", async () => {
}); });
it("ensures that notifications fire when the ETA changes to below threshold", async () => { it("fails if the stop ID doesn't exist", async () => {
}); });
}); });