File tree Expand file tree Collapse file tree
packages/query-persist-client-core/src/__tests__ Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -177,5 +177,39 @@ describe('persist', () => {
177177 expect ( persister . removeClient ) . not . toHaveBeenCalled ( )
178178 expect ( queryClient . getQueryData ( [ 'key' ] ) ) . toBe ( 'data' )
179179 } )
180+
181+ it ( 'should remove the client when the persisted cache is expired' , async ( ) => {
182+ persister . restoreClient = ( ) =>
183+ Promise . resolve ( {
184+ buster : '' ,
185+ clientState : { mutations : [ ] , queries : [ ] } ,
186+ timestamp : Date . now ( ) - 1000 ,
187+ } )
188+
189+ await persistQueryClientRestore ( {
190+ queryClient,
191+ persister,
192+ maxAge : 100 ,
193+ } )
194+
195+ expect ( persister . removeClient ) . toHaveBeenCalledTimes ( 1 )
196+ } )
197+
198+ it ( 'should remove the client when the buster does not match' , async ( ) => {
199+ persister . restoreClient = ( ) =>
200+ Promise . resolve ( {
201+ buster : 'old-buster' ,
202+ clientState : { mutations : [ ] , queries : [ ] } ,
203+ timestamp : Date . now ( ) ,
204+ } )
205+
206+ await persistQueryClientRestore ( {
207+ queryClient,
208+ persister,
209+ buster : 'new-buster' ,
210+ } )
211+
212+ expect ( persister . removeClient ) . toHaveBeenCalledTimes ( 1 )
213+ } )
180214 } )
181215} )
You can’t perform that action at this time.
0 commit comments