mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
update tests to match new repository behavior
This commit is contained in:
@@ -303,28 +303,15 @@ describe("UnoptimizedInMemoryRepository", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("addOrUpdateSystem", () => {
|
||||
test("adds a new system if nonexistent", async () => {
|
||||
describe("updateSystem", () => {
|
||||
test("adds a new system", async () => {
|
||||
const mockSystems = generateMockSystems();
|
||||
const newSystem = mockSystems[0];
|
||||
|
||||
await repository.updateSystem(newSystem);
|
||||
|
||||
const result = await repository.getSystemIfExists();
|
||||
expect(result).toEqual([newSystem]);
|
||||
});
|
||||
|
||||
test("updates an existing system if it exists", async () => {
|
||||
const mockSystems = generateMockSystems();
|
||||
const existingSystem = mockSystems[0];
|
||||
const updatedSystem = structuredClone(existingSystem);
|
||||
updatedSystem.name = "Updated System";
|
||||
|
||||
await repository.updateSystem(existingSystem);
|
||||
await repository.updateSystem(updatedSystem);
|
||||
|
||||
const result = await repository.getSystemIfExists();
|
||||
expect(result).toEqual([updatedSystem]);
|
||||
expect(result).toEqual(newSystem);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -634,18 +621,6 @@ describe("UnoptimizedInMemoryRepository", () => {
|
||||
});
|
||||
|
||||
describe("clearSystemData", () => {
|
||||
test("clears all systems from the repository", async () => {
|
||||
const mockSystems = generateMockSystems();
|
||||
for (const system of mockSystems) {
|
||||
await repository.updateSystem(system);
|
||||
}
|
||||
|
||||
await repository.clearSystemData();
|
||||
|
||||
const result = await repository.getSystemIfExists();
|
||||
expect(result).toEqual([]);
|
||||
});
|
||||
|
||||
test("clears system data when the repository has data", async () => {
|
||||
const mockSystems = generateMockSystems();
|
||||
const system = mockSystems[0];
|
||||
@@ -654,7 +629,7 @@ describe("UnoptimizedInMemoryRepository", () => {
|
||||
await repository.clearSystemData();
|
||||
|
||||
const result = await repository.getSystemIfExists();
|
||||
expect(result).toEqual([]);
|
||||
expect(result).toEqual(null);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user