Skip to content

Commit 2901a19

Browse files
author
Julian Roeland
committed
✅ - test: fixed test
1 parent 04e9294 commit 2901a19

File tree

1 file changed

+6
-24
lines changed

1 file changed

+6
-24
lines changed

frontend/src/hooks/useFields.test.ts

+6-24
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
import { TypedField } from "@maykin-ui/admin-ui";
22
import { act, renderHook, waitFor } from "@testing-library/react";
33

4-
import { selectieLijstKlasseFactory as mockSelectieLijstKlasseFactory } from "../fixtures/selectieLijstKlasseChoices";
5-
import {
6-
listSelectielijstKlasseChoices,
7-
listZaaktypeChoices,
8-
} from "../lib/api/private";
94
import * as fieldSelection from "../lib/fieldSelection/fieldSelection";
105
import { useDataFetcher } from "./useDataFetcher";
116
import { useFields } from "./useFields";
@@ -28,23 +23,7 @@ jest.mock("react-router-dom", () => ({
2823
describe("useFields Hook", () => {
2924
beforeEach(() => {
3025
jest.clearAllMocks();
31-
32-
// Return different data based on the fetch function
33-
(useDataFetcher as jest.Mock).mockImplementation((fetchFunction) => {
34-
if (fetchFunction === listSelectielijstKlasseChoices) {
35-
return {
36-
data: mockSelectieLijstKlasseFactory(),
37-
loading: false,
38-
error: false,
39-
};
40-
}
41-
if (fetchFunction === listZaaktypeChoices) {
42-
return {
43-
data: undefined,
44-
loading: false,
45-
error: false,
46-
};
47-
}
26+
(useDataFetcher as jest.Mock).mockImplementation(() => {
4827
return { data: [], loading: false, error: false };
4928
});
5029
});
@@ -127,9 +106,12 @@ describe("useFields Hook", () => {
127106
});
128107
});
129108

130-
it("should provide selectielijst klasse options to selectielijst klasse field", async () => {
131-
const { result } = await act(async () => renderHook(() => useFields()));
109+
it.only("should provide selectielijst klasse options to selectielijst klasse field", async () => {
110+
(useDataFetcher as jest.Mock).mockImplementation(() => {
111+
return { data: [{ value: "https://" }], loading: false, error: false };
112+
});
132113

114+
const { result } = await act(async () => renderHook(() => useFields()));
133115
const [fields] = result.current;
134116
const selectielijstKlasse = fields.find(
135117
(f) => f.name === "selectielijstklasse",

0 commit comments

Comments
 (0)