mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
add test case for successful system response
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { beforeEach, describe, it, jest, test } from "@jest/globals";
|
||||
import { beforeEach, describe, expect, it, jest, test } from "@jest/globals";
|
||||
import { ApiBasedRepositoryLoader } from "../../src/loaders/ApiBasedRepositoryLoader";
|
||||
import { UnoptimizedInMemoryRepository } from "../../src/repositories/UnoptimizedInMemoryRepository";
|
||||
import { getAllSystemsResponse } from "../jsonSnapshots/getAllSystemsResponse";
|
||||
|
||||
function updateGlobalFetchMockJson(obj: any) {
|
||||
// @ts-ignore
|
||||
@@ -29,7 +30,17 @@ describe("ApiBasedRepositoryLoader", () => {
|
||||
|
||||
describe("fetchAndUpdateSystemData", () => {
|
||||
it("updates system data in repository if response received", async () => {
|
||||
const numberOfSystemsInResponse = getAllSystemsResponse.all.length;
|
||||
updateGlobalFetchMockJson(getAllSystemsResponse);
|
||||
|
||||
await loader.fetchAndUpdateSystemData();
|
||||
|
||||
const systems = await loader.repository.getSystems();
|
||||
if (loader.supportedSystemIds.length < numberOfSystemsInResponse) {
|
||||
expect(systems).toHaveLength(loader.supportedSystemIds.length);
|
||||
} else {
|
||||
expect(systems).toHaveLength(numberOfSystemsInResponse);
|
||||
}
|
||||
});
|
||||
|
||||
it("throws the correct error if the API response contains no data", async () => {
|
||||
|
||||
Reference in New Issue
Block a user