@@ -48,6 +48,145 @@ describe('Queryable write operations', () => {
4848 } ) ;
4949 } ) ;
5050
51+ it ( 'queries writable operations with a specific body for useQueries' , async ( ) => {
52+ const queryClient = new QueryClient ( ) ;
53+ const qraft = createAPIClient ( {
54+ requestFn,
55+ baseUrl,
56+ queryClient,
57+ } ) ;
58+
59+ const parameters = {
60+ header : {
61+ 'x-monite-version' : '1' ,
62+ 'x-monite-entity-id' : '2' ,
63+ } ,
64+ path : {
65+ approval_policy_id : '2' ,
66+ } ,
67+ body : {
68+ name : 'New Name' ,
69+ description : 'New Description' ,
70+ } ,
71+ } ;
72+
73+ const queryKeyParameters = {
74+ ...parameters ,
75+ body : {
76+ name : 'Another Name' ,
77+ description : 'Another Description' ,
78+ } ,
79+ } ;
80+
81+ const queryKey =
82+ qraft . approvalPolicies . patchApprovalPoliciesId . getQueryKey (
83+ queryKeyParameters
84+ ) ;
85+
86+ const { result } = renderHook (
87+ ( ) =>
88+ qraft . approvalPolicies . patchApprovalPoliciesId . useQueries ( {
89+ queries : [ { parameters } , { queryKey } ] ,
90+ } ) ,
91+ {
92+ wrapper : ( props ) => (
93+ < QueryClientProvider client = { queryClient } { ...props } />
94+ ) ,
95+ }
96+ ) ;
97+
98+ await waitFor ( ( ) => {
99+ expect ( result . current [ 0 ] ?. data ) . toEqual ( {
100+ id : '2' ,
101+ name : 'New Name' ,
102+ description : 'New Description' ,
103+ } ) ;
104+ expect ( result . current [ 1 ] ?. data ) . toEqual ( {
105+ id : '2' ,
106+ name : 'Another Name' ,
107+ description : 'Another Description' ,
108+ } ) ;
109+ } ) ;
110+ } ) ;
111+
112+ it ( 'queries writable operations with a specific body for useSuspenseQueries' , async ( ) => {
113+ const queryClient = new QueryClient ( ) ;
114+ const qraft = createAPIClient ( {
115+ requestFn,
116+ baseUrl,
117+ queryClient,
118+ } ) ;
119+
120+ const parameters = {
121+ header : {
122+ 'x-monite-version' : '1' ,
123+ 'x-monite-entity-id' : '2' ,
124+ } ,
125+ path : {
126+ approval_policy_id : '2' ,
127+ } ,
128+ body : {
129+ name : 'New Name' ,
130+ description : 'New Description' ,
131+ } ,
132+ } ;
133+
134+ const queryKeyParameters = {
135+ ...parameters ,
136+ body : {
137+ name : 'Another Name' ,
138+ description : 'Another Description' ,
139+ } ,
140+ } ;
141+
142+ const queryKey =
143+ qraft . approvalPolicies . patchApprovalPoliciesId . getQueryKey (
144+ queryKeyParameters
145+ ) ;
146+
147+ const hook = ( ) => {
148+ try {
149+ return qraft . approvalPolicies . patchApprovalPoliciesId . useSuspenseQueries (
150+ {
151+ queries : [ { parameters } , { queryKey } ] ,
152+ }
153+ ) ;
154+ } catch ( error ) {
155+ return error as Promise < void > ;
156+ }
157+ } ;
158+
159+ const { result : resultWithErrorPromise } = renderHook ( hook , {
160+ wrapper : ( props ) => (
161+ < QueryClientProvider client = { queryClient } { ...props } />
162+ ) ,
163+ } ) ;
164+
165+ expect ( resultWithErrorPromise . current ) . toBeInstanceOf ( Promise ) ;
166+ await resultWithErrorPromise . current ;
167+
168+ const { result : resultWithData } = renderHook ( hook , {
169+ wrapper : ( props ) => (
170+ < QueryClientProvider client = { queryClient } { ...props } />
171+ ) ,
172+ } ) ;
173+
174+ if ( resultWithData . current instanceof Promise ) {
175+ throw new Error ( 'Promise should be resolved' ) ;
176+ }
177+
178+ expect ( resultWithData . current [ 0 ] . data ) . toEqual ( {
179+ id : '2' ,
180+ name : 'New Name' ,
181+ description : 'New Description' ,
182+ } ) ;
183+ expect ( resultWithData . current [ 1 ] . data ) . toEqual ( {
184+ id : '2' ,
185+ name : 'Another Name' ,
186+ description : 'Another Description' ,
187+ } ) ;
188+ } ) ;
189+
51190 it ( 'queries writable operations with a specific body for fetchQuery' , async ( ) => {
52191 const queryClient = new QueryClient ( ) ;
53192 const qraft = createAPIClient ( {
0 commit comments