From 570ab8a17826938e21076311408f0075633600b4 Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Tue, 29 Apr 2025 16:18:46 -0700 Subject: [PATCH] update tests and mock data generators --- ...iBasedParkingRepositoryLoaderTests.test.ts | 2 + .../ETANotificationSchedulerTests.test.ts | 1 + .../InMemoryParkingRepositoryTests.test.ts | 3 +- test/testHelpers/mockDataGenerators.ts | 41 +++++++++++-------- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/test/loaders/parking/ChapmanApiBasedParkingRepositoryLoaderTests.test.ts b/test/loaders/parking/ChapmanApiBasedParkingRepositoryLoaderTests.test.ts index 9d9ebfc..b92026e 100644 --- a/test/loaders/parking/ChapmanApiBasedParkingRepositoryLoaderTests.test.ts +++ b/test/loaders/parking/ChapmanApiBasedParkingRepositoryLoaderTests.test.ts @@ -59,6 +59,7 @@ describe("ChapmanApiBasedParkingRepositoryLoader", () => { }, name: "Anderson Structure", id: "", + updatedTimeMs: Date.now(), }, { address: "200 W Sycamore Ave, Orange, CA 92866-1053", @@ -70,6 +71,7 @@ describe("ChapmanApiBasedParkingRepositoryLoader", () => { }, name: "Barrera", id: "", + updatedTimeMs: Date.now(), } ]; expectedStructures[0].id = ChapmanApiBasedParkingRepositoryLoader.generateId(expectedStructures[0].address); diff --git a/test/notifications/schedulers/ETANotificationSchedulerTests.test.ts b/test/notifications/schedulers/ETANotificationSchedulerTests.test.ts index db6a94b..136dd16 100644 --- a/test/notifications/schedulers/ETANotificationSchedulerTests.test.ts +++ b/test/notifications/schedulers/ETANotificationSchedulerTests.test.ts @@ -52,6 +52,7 @@ describe("ETANotificationScheduler", () => { stopId: stop.id, secondsRemaining: 120, systemId: "1", + updatedTimeMs: Date.now(), }; const notificationData1 = { diff --git a/test/repositories/InMemoryParkingRepositoryTests.test.ts b/test/repositories/InMemoryParkingRepositoryTests.test.ts index b656c81..2e541bf 100644 --- a/test/repositories/InMemoryParkingRepositoryTests.test.ts +++ b/test/repositories/InMemoryParkingRepositoryTests.test.ts @@ -13,7 +13,8 @@ describe("InMemoryParkingRepository", () => { id: "1", name: "Anderson Parking Structure", capacity: 100, - address: "300 E Walnut Ave, Orange, CA 92867" + address: "300 E Walnut Ave, Orange, CA 92867", + updatedTimeMs: Date.now(), }; beforeEach(() => { diff --git a/test/testHelpers/mockDataGenerators.ts b/test/testHelpers/mockDataGenerators.ts index b28cff7..64f2cbc 100644 --- a/test/testHelpers/mockDataGenerators.ts +++ b/test/testHelpers/mockDataGenerators.ts @@ -16,7 +16,8 @@ export function generateParkingStructures(): IParkingStructure[] { "id": "b0723baf8a6b8bcc37c821473373049e", "name": "Anderson Structure", "spotsAvailable": 163, - "address": "300 E Walnut, Orange, CA 92867" + "address": "300 E Walnut, Orange, CA 92867", + updatedTimeMs: Date.now(), }, { "capacity": 692, @@ -27,7 +28,8 @@ export function generateParkingStructures(): IParkingStructure[] { "id": "81b9e1ed004cf6def2e6c568aaf79ece", "name": "Barrera", "spotsAvailable": 179, - "address": "200 W Sycamore Ave, Orange, CA 92866-1053" + "address": "200 W Sycamore Ave, Orange, CA 92866-1053", + updatedTimeMs: Date.now(), } ]; } @@ -43,7 +45,8 @@ export function generateMockShuttles(): IShuttle[] { latitude: 10, longitude: 20 }, - orientationInDegrees: 25.163 + orientationInDegrees: 25.163, + updatedTimeMs: Date.now(), }, { id: "sh2", @@ -54,7 +57,8 @@ export function generateMockShuttles(): IShuttle[] { latitude: 15, longitude: 25 }, - orientationInDegrees: 50.912 + orientationInDegrees: 50.912, + updatedTimeMs: Date.now(), }, { id: "sh3", @@ -65,40 +69,41 @@ export function generateMockShuttles(): IShuttle[] { latitude: 30, longitude: 40 }, - orientationInDegrees: 321.019 + orientationInDegrees: 321.019, + updatedTimeMs: Date.now(), }, ]; } export function generateMockRoutes(): IRoute[] { return [ - { id: "r1", name: "Route 1", color: "red", systemId: "sys1", polylineCoordinates: [] }, - { id: "r2", name: "Route 2", color: "blue", systemId: "sys2", polylineCoordinates: [] }, - { id: "r3", name: "Route 3", color: "green", systemId: "sys3", polylineCoordinates: [] }, + { id: "r1", name: "Route 1", color: "red", systemId: "sys1", polylineCoordinates: [], updatedTimeMs: Date.now() }, + { id: "r2", name: "Route 2", color: "blue", systemId: "sys2", polylineCoordinates: [], updatedTimeMs: Date.now() }, + { id: "r3", name: "Route 3", color: "green", systemId: "sys3", polylineCoordinates: [], updatedTimeMs: Date.now() }, ]; } export function generateMockStops(): IStop[] { return [ - { id: "st1", name: "Stop A", systemId: "sys1", coordinates: { latitude: 10, longitude: 20 } }, - { id: "st2", name: "Stop B", systemId: "sys2", coordinates: { latitude: 15, longitude: 25 } }, - { id: "st3", name: "Stop C", systemId: "sys3", coordinates: { latitude: 30, longitude: 40 } }, + { id: "st1", name: "Stop A", systemId: "sys1", coordinates: { latitude: 10, longitude: 20 }, updatedTimeMs: Date.now() }, + { id: "st2", name: "Stop B", systemId: "sys2", coordinates: { latitude: 15, longitude: 25 }, updatedTimeMs: Date.now() }, + { id: "st3", name: "Stop C", systemId: "sys3", coordinates: { latitude: 30, longitude: 40 }, updatedTimeMs: Date.now() }, ]; } export function generateMockOrderedStops(): IOrderedStop[] { return [ - { stopId: "st1", routeId: "r1", position: 1, systemId: "sys1" }, - { stopId: "st1", routeId: "r2", position: 2, systemId: "sys1" }, - { stopId: "st2", routeId: "r1", position: 3, systemId: "sys1" }, - { stopId: "st2", routeId: "r2", position: 4, systemId: "sys1" }, + { stopId: "st1", routeId: "r1", position: 1, systemId: "sys1", updatedTimeMs: Date.now(), }, + { stopId: "st1", routeId: "r2", position: 2, systemId: "sys1", updatedTimeMs: Date.now(), }, + { stopId: "st2", routeId: "r1", position: 3, systemId: "sys1", updatedTimeMs: Date.now(), }, + { stopId: "st2", routeId: "r2", position: 4, systemId: "sys1", updatedTimeMs: Date.now(), }, ]; } export function generateMockEtas(): IEta[] { return [ - { shuttleId: "sh1", stopId: "st1", secondsRemaining: 120, systemId: "sys1" }, - { shuttleId: "sh1", stopId: "st2", secondsRemaining: 180, systemId: "sys1" }, - { shuttleId: "sh2", stopId: "st3", secondsRemaining: 240, systemId: "sys1" }, + { shuttleId: "sh1", stopId: "st1", secondsRemaining: 120, systemId: "sys1", updatedTimeMs: Date.now() }, + { shuttleId: "sh1", stopId: "st2", secondsRemaining: 180, systemId: "sys1", updatedTimeMs: Date.now() }, + { shuttleId: "sh2", stopId: "st3", secondsRemaining: 240, systemId: "sys1", updatedTimeMs: Date.now() }, ]; }