Skip to content

Commit

Permalink
Tests for API and utils on FIMS history
Browse files Browse the repository at this point in the history
  • Loading branch information
Vangaorth committed Nov 4, 2024
1 parent b8622e1 commit 5b797ff
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
28 changes: 28 additions & 0 deletions ts/features/fims/history/api/__tests__/client.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import * as fimsClient from "../../../../../../definitions/fims/client";
import * as fetchUtils from "../../../../../utils/fetch";
import { createFimsClient } from "../client";

describe("createFimsClient", () => {
it("should invoke `createClient` with the input 'baseUrl' and the result of `defaultRetryingFetch`", () => {
const mockFetch = jest.fn();
const spyDefaultRetryingFetch = jest
.spyOn(fetchUtils, "defaultRetryingFetch")
.mockImplementation((_timeout, _maxRetries) => mockFetch);
const mockCreateClient = jest.fn();
jest
.spyOn(fimsClient, "createClient")
.mockImplementation(input => mockCreateClient(input));

const baseUrl = "https://localhost:3000";
createFimsClient(baseUrl);

expect(mockCreateClient.mock.calls.length).toBe(1);
expect(mockCreateClient.mock.calls[0].length).toBe(1);
expect(mockCreateClient.mock.calls[0][0]).toEqual({
baseUrl,
fetchApi: mockFetch
});
expect(spyDefaultRetryingFetch.mock.calls.length).toBe(1);
expect(spyDefaultRetryingFetch.mock.calls[0].length).toBe(0);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`FimsHistorySharedStyles should match snapshot 1`] = `
{
"fixedHeightListItem": {
"height": 117,
"justifyContent": "center",
},
}
`;
7 changes: 7 additions & 0 deletions ts/features/fims/history/utils/__tests__/styles.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { FimsHistorySharedStyles } from "../styles";

describe("FimsHistorySharedStyles", () => {
it("should match snapshot", () => {
expect(FimsHistorySharedStyles).toMatchSnapshot();
});
});

0 comments on commit 5b797ff

Please sign in to comment.