@@ -2,7 +2,6 @@ import { createApi } from '@reduxjs/toolkit/query'
22import { delay } from 'msw'
33import { setupApiStore } from './helpers'
44import type { SubscriptionSelectors } from '../core/buildMiddleware/types'
5- import { createListenerMiddleware } from '@reduxjs/toolkit'
65
76const mockBaseQuery = vi
87 . fn ( )
@@ -126,26 +125,18 @@ describe('polling tests', () => {
126125
127126 it ( 'respects skipPollOnFocusLost' , async ( ) => {
128127 mockBaseQuery . mockClear ( )
129- const listenerMiddleware = createListenerMiddleware ( )
130- const storeListenerRef = setupApiStore ( api , undefined , {
131- middleware : {
132- concat : [ listenerMiddleware . middleware ] ,
133- } ,
134- withoutTestLifecycles : true ,
135- } )
136-
137- storeListenerRef . store . dispatch (
128+ storeRef . store . dispatch (
138129 getPosts . initiate ( 2 , {
139130 subscriptionOptions : { pollingInterval : 10 , skipPollOnFocusLost : true } ,
140131 subscribe : true ,
141132 } )
142133 )
143- storeListenerRef . store . dispatch ( api . internalActions ?. onFocusLost ( ) )
134+ storeRef . store . dispatch ( api . internalActions ?. onFocusLost ( ) )
144135
145136 await delay ( 50 )
146137 const callsWithSkip = mockBaseQuery . mock . calls . length
147138
148- storeListenerRef . store . dispatch (
139+ storeRef . store . dispatch (
149140 getPosts . initiate ( 2 , {
150141 subscriptionOptions : {
151142 pollingInterval : 10 ,
@@ -155,27 +146,19 @@ describe('polling tests', () => {
155146 } )
156147 )
157148
158- storeListenerRef . store . dispatch ( api . internalActions ?. onFocus ( ) )
149+ storeRef . store . dispatch ( api . internalActions ?. onFocus ( ) )
159150
160151 await delay ( 50 )
161152 const callsWithoutSkip = mockBaseQuery . mock . calls . length
162153
163154 expect ( callsWithSkip ) . toBe ( 1 )
164155 expect ( callsWithoutSkip ) . toBeGreaterThan ( 2 )
165156
166- storeListenerRef . store . dispatch ( api . util . resetApiState ( ) )
157+ storeRef . store . dispatch ( api . util . resetApiState ( ) )
167158 } )
168159
169160 it ( 'respects skipPollOnFocusLost of the most recent mounted subscription' , async ( ) => {
170- const listenerMiddleware = createListenerMiddleware ( )
171- const storeListenerRef = setupApiStore ( api , undefined , {
172- middleware : {
173- concat : [ listenerMiddleware . middleware ] ,
174- } ,
175- withoutTestLifecycles : true ,
176- } )
177-
178- storeListenerRef . store . dispatch (
161+ storeRef . store . dispatch (
179162 getPosts . initiate ( 3 , {
180163 subscriptionOptions : {
181164 pollingInterval : 10 ,
@@ -188,14 +171,14 @@ describe('polling tests', () => {
188171 await delay ( 50 )
189172 const callsWithSkip = mockBaseQuery . mock . calls . length
190173
191- storeListenerRef . store . dispatch (
174+ storeRef . store . dispatch (
192175 getPosts . initiate ( 3 , {
193176 subscriptionOptions : { pollingInterval : 15 , skipPollOnFocusLost : true } ,
194177 subscribe : true ,
195178 } )
196179 )
197180
198- storeListenerRef . store . dispatch ( api . internalActions ?. onFocusLost ( ) )
181+ storeRef . store . dispatch ( api . internalActions ?. onFocusLost ( ) )
199182
200183 await delay ( 50 )
201184 const callsWithoutSkip = mockBaseQuery . mock . calls . length
0 commit comments