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