fix method calls and tests

This commit is contained in:
2025-03-27 10:56:57 -07:00
parent a665c29745
commit ef94a9aa7e
4 changed files with 17 additions and 16 deletions

View File

@@ -38,13 +38,13 @@ describe("MutationResolvers", () => {
}
`
function assertFailedResponse(response: any, notificationInput: NotificationInput) {
async function assertFailedResponse(response: any, notificationInput: NotificationInput) {
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);
expect(context.notificationRepository.isNotificationScheduled(notificationInput)).toBe(false);
expect(await context.notificationRepository.isNotificationScheduled(notificationInput)).toBe(false);
}
@@ -72,7 +72,7 @@ describe("MutationResolvers", () => {
expect(notificationResponse?.success).toBe(true);
expect(notificationResponse?.data).toEqual(expectedNotificationData);
expect(context.notificationRepository.getSecondsThresholdForScheduledNotification(expectedNotificationData)).toBe(240);
expect(await context.notificationRepository.getSecondsThresholdForNotificationIfExists(expectedNotificationData)).toBe(240);
});
it("adds a notification with the default seconds threshold if none is provided", async () => {
@@ -93,7 +93,7 @@ describe("MutationResolvers", () => {
const notificationResponse = response.body.singleResult.data?.scheduleNotification as any;
expect(notificationResponse?.success).toBe(true);
expect(context.notificationRepository.getSecondsThresholdForScheduledNotification(notificationInput)).toBe(180);
expect(await context.notificationRepository.getSecondsThresholdForNotificationIfExists(notificationInput)).toBe(180);
});
it("fails if the shuttle ID doesn't exist", async () => {
@@ -106,7 +106,7 @@ describe("MutationResolvers", () => {
stopId: stop.id,
}
const response = await getServerResponse(query, notificationInput);
assertFailedResponse(response, notificationInput);
await assertFailedResponse(response, notificationInput);
});
it("fails if the stop ID doesn't exist", async () => {
@@ -120,7 +120,7 @@ describe("MutationResolvers", () => {
}
const response = await getServerResponse(query, notificationInput);
assertFailedResponse(response, notificationInput);
await assertFailedResponse(response, notificationInput);
});
});
@@ -150,7 +150,7 @@ describe("MutationResolvers", () => {
stopId: stop.id,
secondsThreshold: 180,
}
await context.notificationRepository.scheduleNotification(notificationInput);
await context.notificationRepository.addOrUpdateNotification(notificationInput);
const notificationLookup = {
...notificationInput
@@ -166,7 +166,7 @@ describe("MutationResolvers", () => {
expect(notificationResponse.success).toBe(true);
expect(notificationResponse.data).toEqual(notificationLookup);
expect(context.notificationRepository.isNotificationScheduled(notificationLookup)).toBe(false);
expect(await context.notificationRepository.isNotificationScheduled(notificationLookup)).toBe(false);
});
it("fails if the notification doesn't exist", async () => {