add test cases and documentation for functions

This commit is contained in:
2025-02-02 13:04:03 -08:00
parent 345d4905fe
commit 5957010a7f
2 changed files with 26 additions and 2 deletions

View File

@@ -17,7 +17,23 @@ export interface GetterRepository {
getEtasForShuttleId(shuttleId: string): Promise<IEta[]>;
getEtasForStopId(stopId: string): Promise<IEta[]>;
getEtaForShuttleAndStopId(shuttleId: string, stopId: string): Promise<IEta | null>;
subscribeToEtaChanges(listener: (eta: IEta) => void): Promise<void>;
/**
* Subscribe to all updates in ETA data.
* The subscriber persists even if the ETA data does not
* exist within the repository, and may fire again
* if ETA data is restored.
* @param listener
*/
subscribeToEtaChanges(
listener: (eta: IEta) => void,
): Promise<void>;
/**
* Unsubscribe from all ETA updates for the given callback.
* Callback must be passed by reference.
* @param listener
*/
unsubscribeFromEtaChanges(listener: (eta: IEta) => void): Promise<void>;
getOrderedStopByRouteAndStopId(routeId: string, stopId: string): Promise<IOrderedStop | null>;

View File

@@ -225,6 +225,14 @@ describe("UnoptimizedInMemoryRepository", () => {
});
});
describe("subscribeToEtaChanges", () => {
test("notifies listener if the eta has changed")
});
describe("unsubscribeFromEtaChanges", () => {
});
describe("getOrderedStopByRouteAndStopId", () => {
test("gets an ordered stop by route ID and stop ID", async () => {
const mockOrderedStops = generateMockOrderedStops();
@@ -711,4 +719,4 @@ describe("UnoptimizedInMemoryRepository", () => {
expect(result).toEqual([]);
});
});
});
});