update system test to add some systems to prune

This commit is contained in:
2025-01-22 21:10:50 -08:00
parent d58495d8b4
commit a8594032bc

View File

@@ -33,11 +33,19 @@ describe("ApiBasedRepositoryLoader", () => {
describe("fetchAndUpdateSystemData", () => { describe("fetchAndUpdateSystemData", () => {
it("updates system data in repository if response received", async () => { it("updates system data in repository if response received", async () => {
// Arrange
const systemsToPrune = generateMockSystems();
await Promise.all(systemsToPrune.map(async (system) => {
await loader.repository.addOrUpdateSystem(system);
}));
const numberOfSystemsInResponse = fetchSystemDataSuccessfulResponse.all.length; const numberOfSystemsInResponse = fetchSystemDataSuccessfulResponse.all.length;
updateGlobalFetchMockJson(fetchSystemDataSuccessfulResponse); updateGlobalFetchMockJson(fetchSystemDataSuccessfulResponse);
// Act
await loader.fetchAndUpdateSystemData(); await loader.fetchAndUpdateSystemData();
// Assert
const systems = await loader.repository.getSystems(); const systems = await loader.repository.getSystems();
if (loader.supportedSystemIds.length < numberOfSystemsInResponse) { if (loader.supportedSystemIds.length < numberOfSystemsInResponse) {
expect(systems).toHaveLength(loader.supportedSystemIds.length); expect(systems).toHaveLength(loader.supportedSystemIds.length);