Add implementation and tests for ParkingStructureResolvers.ts

This commit is contained in:
2025-07-21 19:06:00 -04:00
parent ee7b5eefda
commit e78982538e
3 changed files with 60 additions and 12 deletions

View File

@@ -0,0 +1,36 @@
// Tests that run exclusively for the in-memory repo
import { beforeEach, describe, expect, it, jest } from "@jest/globals";
import { InMemoryParkingRepository } from "../../src/repositories/parking/InMemoryParkingRepository";
describe("InMemoryParkingRepositoryTests", () => {
let repository = new InMemoryParkingRepository();
beforeEach(() => {
repository = new InMemoryParkingRepository();
});
describe("getHistoricalAveragesOfParkingStructureCounts", () => {
it("gets correct data for historical averages", async () => {
// jest.useFakeTimers();
// jest.setSystemTime(new Date());
//
// const parkingStructure = generateParkingStructures()[0];
// parkingStructure.spotsAvailable = parkingStructure.capacity;
// mockSystem.parkingRepository?.setLoggingInterval(100);
//
// // Simulate repeated updates
// for (let i = 0; i < 6; i += 1) {
// jest.setSystemTime(new Date(Date.now() + 1000));
// parkingStructure.spotsAvailable = parkingStructure.spotsAvailable - 100;
// parkingStructureCounts.push(parkingStructure.spotsAvailable);
// await mockSystem.parkingRepository?.addOrUpdateParkingStructure(parkingStructure);
// }
// TODO: Make these assertions for this repository
// expect(historicalAverages[0].averageSpotsAvailable).toBeCloseTo((parkingStructureCounts[0] + parkingStructureCounts[1]) / 2);
// expect(historicalAverages[1].averageSpotsAvailable).toBeCloseTo((parkingStructureCounts[2] + parkingStructureCounts[3]) / 2);
// expect(historicalAverages[2].averageSpotsAvailable).toBeCloseTo((parkingStructureCounts[4] + parkingStructureCounts[5]) / 2);
});
});
});