mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
Update InMemoryParkingRepository.ts and tests to use the circular queue
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import { beforeEach, describe, expect, it, jest } from "@jest/globals";
|
||||
import {
|
||||
InMemoryParkingRepository,
|
||||
PARKING_LOGGING_INTERVAL_MS
|
||||
PARKING_LOGGING_INTERVAL_MS, ParkingStructureID
|
||||
} from "../../src/repositories/InMemoryParkingRepository";
|
||||
import { IParkingStructure } from "../../src/entities/ParkingRepositoryEntities";
|
||||
import { IParkingStructure, IParkingStructureTimestampRecord } from "../../src/entities/ParkingRepositoryEntities";
|
||||
import { CircularQueue } from "../../src/types/CircularQueue";
|
||||
|
||||
describe("InMemoryParkingRepository", () => {
|
||||
let repository: InMemoryParkingRepository;
|
||||
@@ -19,7 +20,7 @@ describe("InMemoryParkingRepository", () => {
|
||||
address: "300 E Walnut Ave, Orange, CA 92867",
|
||||
updatedTime: new Date(),
|
||||
};
|
||||
let historicalData = new Map();
|
||||
let historicalData: Map<ParkingStructureID, CircularQueue<IParkingStructureTimestampRecord>> = new Map();
|
||||
|
||||
beforeEach(() => {
|
||||
historicalData = new Map();
|
||||
@@ -57,8 +58,8 @@ describe("InMemoryParkingRepository", () => {
|
||||
jest.setSystemTime(now + PARKING_LOGGING_INTERVAL_MS + 60);
|
||||
await repository.addOrUpdateParkingStructure(testStructure);
|
||||
|
||||
expect(historicalData.get(testStructure.id)).toContainEqual(expectedTimestampRecordMatcher);
|
||||
expect(historicalData.get(testStructure.id)).toContainEqual({
|
||||
expect(historicalData.get(testStructure.id)?.get(0)).toEqual(expectedTimestampRecordMatcher);
|
||||
expect(historicalData.get(testStructure.id)?.get(1)).toEqual({
|
||||
...expectedTimestampRecordMatcher,
|
||||
timestampMs: now + PARKING_LOGGING_INTERVAL_MS + 60,
|
||||
});
|
||||
@@ -74,7 +75,7 @@ describe("InMemoryParkingRepository", () => {
|
||||
jest.setSystemTime(now + 60);
|
||||
await repository.addOrUpdateParkingStructure(testStructure);
|
||||
|
||||
expect(historicalData.get(testStructure.id)).toHaveLength(1);
|
||||
expect(historicalData.get(testStructure.id)?.size()).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user