@@ -192,7 +192,7 @@ describe('updateQueryData', () => {
192192 expect ( result . current . data ) . toEqual ( dataBefore )
193193 } )
194194
195- test . only ( 'updates cache values including provided tags, undos that' , async ( ) => {
195+ test ( 'updates (list) cache values including provided tags, undos that' , async ( ) => {
196196 baseQuery
197197 . mockResolvedValueOnce ( [
198198 {
@@ -253,6 +253,65 @@ describe('updateQueryData', () => {
253253 expect ( provided4Next ) . toEqual ( [ ] )
254254 } )
255255
256+ test ( 'updates (list) cache values excluding provided tags, undos that' , async ( ) => {
257+ baseQuery
258+ . mockResolvedValueOnce ( [
259+ {
260+ id : '3' ,
261+ title : 'All about cheese.' ,
262+ contents : 'TODO' ,
263+ } ,
264+ ] )
265+ . mockResolvedValueOnce ( 42 )
266+ const { result } = renderHook ( ( ) => api . endpoints . listPosts . useQuery ( ) , {
267+ wrapper : storeRef . wrapper ,
268+ } )
269+ await hookWaitFor ( ( ) => expect ( result . current . isSuccess ) . toBeTruthy ( ) )
270+
271+ let provided ! : InvalidationState < 'Post' >
272+ act ( ( ) => {
273+ provided = storeRef . store . getState ( ) . api . provided
274+ } )
275+
276+ let returnValue ! : ReturnType < ReturnType < typeof api . util . updateQueryData > >
277+ act ( ( ) => {
278+ returnValue = storeRef . store . dispatch (
279+ api . util . updateQueryData (
280+ 'listPosts' ,
281+ undefined ,
282+ ( draft ) => {
283+ draft . push ( {
284+ id : '4' ,
285+ title : 'Mostly about cheese.' ,
286+ contents : 'TODO' ,
287+ } )
288+ } ,
289+ false
290+ )
291+ )
292+ } )
293+
294+ act ( ( ) => {
295+ provided = storeRef . store . getState ( ) . api . provided
296+ } )
297+
298+ const provided4 = provided [ 'Post' ] [ '4' ]
299+
300+ expect ( provided4 ) . toEqual ( undefined )
301+
302+ act ( ( ) => {
303+ returnValue . undo ( )
304+ } )
305+
306+ act ( ( ) => {
307+ provided = storeRef . store . getState ( ) . api . provided
308+ } )
309+
310+ const provided4Next = provided [ 'Post' ] [ '4' ]
311+
312+ expect ( provided4Next ) . toEqual ( undefined )
313+ } )
314+
256315 test ( 'does not update non-existing values' , async ( ) => {
257316 baseQuery
258317 . mockImplementationOnce ( async ( ) => ( {
0 commit comments