1
1
import { TypedField } from "@maykin-ui/admin-ui" ;
2
2
import { act , renderHook , waitFor } from "@testing-library/react" ;
3
3
4
- import { selectieLijstKlasseFactory as mockSelectieLijstKlasseFactory } from "../fixtures/selectieLijstKlasseChoices" ;
5
- import {
6
- listSelectielijstKlasseChoices ,
7
- listZaaktypeChoices ,
8
- } from "../lib/api/private" ;
9
4
import * as fieldSelection from "../lib/fieldSelection/fieldSelection" ;
10
5
import { useDataFetcher } from "./useDataFetcher" ;
11
6
import { useFields } from "./useFields" ;
@@ -28,23 +23,7 @@ jest.mock("react-router-dom", () => ({
28
23
describe ( "useFields Hook" , ( ) => {
29
24
beforeEach ( ( ) => {
30
25
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 ( ( ) => {
48
27
return { data : [ ] , loading : false , error : false } ;
49
28
} ) ;
50
29
} ) ;
@@ -127,9 +106,12 @@ describe("useFields Hook", () => {
127
106
} ) ;
128
107
} ) ;
129
108
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
+ } ) ;
132
113
114
+ const { result } = await act ( async ( ) => renderHook ( ( ) => useFields ( ) ) ) ;
133
115
const [ fields ] = result . current ;
134
116
const selectielijstKlasse = fields . find (
135
117
( f ) => f . name === "selectielijstklasse" ,
0 commit comments