add isNotificationScheduled resolver and test cases

This commit is contained in:
2025-02-12 19:51:42 -08:00
parent e697fd89b8
commit 8971e3514d
2 changed files with 48 additions and 1 deletions

View File

@@ -15,6 +15,9 @@ export const QueryResolvers: Resolvers<ServerContext> = {
name: system.name, name: system.name,
id: system.id, id: system.id,
}; };
},
isNotificationScheduled: async (_parent, args, contextValue, _info) => {
return false;
} }
}, },
} }

View File

@@ -2,6 +2,8 @@ import { describe, expect, it } from "@jest/globals";
import { generateMockSystems } from "../testHelpers/mockDataGenerators"; import { generateMockSystems } from "../testHelpers/mockDataGenerators";
import { setupTestServerContext, setupTestServerHolder } from "../testHelpers/apolloTestServerHelpers"; import { setupTestServerContext, setupTestServerHolder } from "../testHelpers/apolloTestServerHelpers";
import assert = require("node:assert"); import assert = require("node:assert");
import { ScheduledNotificationData } from "../../src/services/NotificationService";
import { addMockShuttleToRepository, addMockStopToRepository } from "../testHelpers/repositorySetupHelpers";
// See Apollo documentation for integration test guide // See Apollo documentation for integration test guide
// https://www.apollographql.com/docs/apollo-server/testing/testing // https://www.apollographql.com/docs/apollo-server/testing/testing
@@ -93,4 +95,46 @@ describe("QueryResolvers", () => {
expect(response.body.singleResult.data?.system).toBeNull(); expect(response.body.singleResult.data?.system).toBeNull();
}); });
}); });
describe("isNotificationScheduled", () => {
const query = `
query IsNotificationScheduled($input: NotificationInput!) {
isNotificationScheduled(input: $input)
}
`
it("returns true if the notification is scheduled", async () => {
// Arrange
const shuttle = await addMockShuttleToRepository(context.repository, "1");
const stop = await addMockStopToRepository(context.repository, "1")
const notification: ScheduledNotificationData = {
shuttleId: shuttle.id,
stopId: stop.id,
deviceId: "1",
};
await context.notificationService.scheduleNotification(notification);
// Act
const response = await holder.testServer.executeOperation({
query,
variables: {
input: {
...notification,
},
}
}, {
contextValue: context,
});
// Assert
assert(response.body.kind === "single");
expect(response.body.singleResult.errors).toBeUndefined();
expect(response.body.singleResult.data?.isNotificationScheduled).toBe(true);
});
it("returns false if the notification isn't scheduled", async () => {
});
});
}); });