mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
update test cases and implement add notification test
This commit is contained in:
@@ -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 () => {
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user