diff --git a/src/notifications/schedulers/ETANotificationScheduler.ts b/src/notifications/schedulers/ETANotificationScheduler.ts index 85e911f..0319cf7 100644 --- a/src/notifications/schedulers/ETANotificationScheduler.ts +++ b/src/notifications/schedulers/ETANotificationScheduler.ts @@ -2,10 +2,7 @@ import { ShuttleGetterRepository } from "../../repositories/ShuttleGetterReposit import { TupleKey } from "../../types/TupleKey"; import { IEta } from "../../entities/entities"; import { AppleNotificationSender, NotificationAlertArguments } from "../senders/AppleNotificationSender"; -import { - NotificationLookupArguments, - ScheduledNotification -} from "../../repositories/NotificationRepository"; +import { NotificationLookupArguments, ScheduledNotification } from "../../repositories/NotificationRepository"; type DeviceIdSecondsThresholdAssociation = { [key: string]: number }; diff --git a/src/repositories/InMemoryNotificationRepository.ts b/src/repositories/InMemoryNotificationRepository.ts new file mode 100644 index 0000000..c660ca7 --- /dev/null +++ b/src/repositories/InMemoryNotificationRepository.ts @@ -0,0 +1,19 @@ +import { NotificationLookupArguments, NotificationRepository, ScheduledNotification } from "./NotificationRepository"; + +export class InMemoryNotificationRepository implements NotificationRepository { + async getAllNotificationsForShuttleAndStopId(shuttleId: string, stopId: string) { + return []; + } + + async getSecondsThresholdForNotificationIfExists(lookupArguments: NotificationLookupArguments) { + return 0; + } + + async addOrUpdateNotification(notification: ScheduledNotification) { + + } + + async deleteNotificationIfExists(lookupArguments: NotificationLookupArguments) { + + } +} diff --git a/src/repositories/NotificationRepository.ts b/src/repositories/NotificationRepository.ts index 7f74914..3787f3d 100644 --- a/src/repositories/NotificationRepository.ts +++ b/src/repositories/NotificationRepository.ts @@ -14,20 +14,9 @@ export interface ScheduledNotification extends NotificationLookupArguments { secondsThreshold: number; } -export class NotificationRepository { - public async getAllNotificationsForShuttleAndStopId(shuttleId: string, stopId: string) { - - } - - public async getSecondsThresholdForNotificationIfExists(lookupArguments: NotificationLookupArguments) { - - } - - public async addOrUpdateNotification(notification: ScheduledNotification) { - - } - - public async deleteNotificationIfExists(lookupArguments: NotificationLookupArguments) { - - } +export interface NotificationRepository { + getAllNotificationsForShuttleAndStopId(shuttleId: string, stopId: string): Promise; + getSecondsThresholdForNotificationIfExists(lookupArguments: NotificationLookupArguments): Promise; + addOrUpdateNotification(notification: ScheduledNotification): Promise; + deleteNotificationIfExists(lookupArguments: NotificationLookupArguments): Promise; } diff --git a/src/resolvers/MutationResolvers.ts b/src/resolvers/MutationResolvers.ts index f512ed5..a840817 100644 --- a/src/resolvers/MutationResolvers.ts +++ b/src/resolvers/MutationResolvers.ts @@ -2,8 +2,8 @@ import { NotificationResponse, Resolvers } from "../generated/graphql"; import { ServerContext } from "../ServerContext"; import { ETANotificationScheduler, - ScheduledNotification } from "../notifications/schedulers/ETANotificationScheduler"; +import { ScheduledNotification } from "../repositories/NotificationRepository"; export const MutationResolvers: Resolvers = { Mutation: { @@ -23,7 +23,7 @@ export const MutationResolvers: Resolvers = { } } - const notificationData: NotificationSchedulingArguments = { + const notificationData: ScheduledNotification = { ...args.input, secondsThreshold: typeof args.input.secondsThreshold === 'number' ? args.input.secondsThreshold diff --git a/test/repositories/NotificationRepositoryTests.test.ts b/test/repositories/NotificationRepositoryTests.test.ts index 9bbe38c..3d4f18b 100644 --- a/test/repositories/NotificationRepositoryTests.test.ts +++ b/test/repositories/NotificationRepositoryTests.test.ts @@ -1,6 +1,6 @@ import { describe, it } from "@jest/globals"; -describe("NotificationRepository", () => { +describe("InMemoryNotificationRepository", () => { describe("getAllNotificationsForShuttleAndStopId", () => { it("gets notifications correctly", async () => {