File tree 1 file changed +33
-1
lines changed
packages/runtime-core/__tests__
1 file changed +33
-1
lines changed Original file line number Diff line number Diff line change 9
9
render ,
10
10
serializeInner ,
11
11
SetupContext ,
12
- Suspense
12
+ Suspense ,
13
+ computed ,
14
+ ComputedRef
13
15
} from '@vue/runtime-test'
14
16
import {
15
17
defineEmits ,
@@ -253,5 +255,35 @@ describe('SFC <script setup> helpers', () => {
253
255
await ready
254
256
expect ( getCurrentInstance ( ) ) . toBeNull ( )
255
257
} )
258
+
259
+ test ( 'should teardown in-scope effects' , async ( ) => {
260
+ let resolve : ( val ?: any ) => void
261
+ const ready = new Promise ( r => {
262
+ resolve = r
263
+ } )
264
+
265
+ let c : ComputedRef
266
+
267
+ const Comp = defineComponent ( {
268
+ async setup ( ) {
269
+ await withAsyncContext ( Promise . resolve ( ) )
270
+
271
+ c = computed ( ( ) => { } )
272
+ // register the lifecycle after an await statement
273
+ onMounted ( resolve )
274
+ return ( ) => ''
275
+ }
276
+ } )
277
+
278
+ const app = createApp ( ( ) => h ( Suspense , ( ) => h ( Comp ) ) )
279
+ const root = nodeOps . createElement ( 'div' )
280
+ app . mount ( root )
281
+
282
+ await ready
283
+ expect ( c ! . effect . active ) . toBe ( true )
284
+
285
+ app . unmount ( )
286
+ expect ( c ! . effect . active ) . toBe ( false )
287
+ } )
256
288
} )
257
289
} )
You can’t perform that action at this time.
0 commit comments