test(cordis): cover cross-fiber adoption of a plain effect disposer

This commit is contained in:
_Kerman committed 2026-10-08 11:22:34 +08:00
1 parent 5578ecf655
commit 9ec9aebca5
1 file changed
+19
@@ -95,6 +95,25 @@ describe('Cordis effect ownership', () => {
expect(ctx.fiber.getEffects()).toEqual([])
})
it('adopts a yielded plain effect disposer away from its creating fiber', async () => {
const ctx = new Context()
const order: string[] = []
let originCtx!: Context
const origin = await ctx.plugin((inner: Context) => { originCtx = inner })
const adopted = originCtx.effect(() => () => { order.push('adopted') }, 'adopted-effect')
const owner = await ctx.plugin((inner: Context) => {
inner.effect(function* () {
yield adopted
yield () => { order.push('owner') }
}, 'composite-effect')
})
await origin.dispose()
expect(order).toEqual([])
await owner.dispose()
expect(order).toEqual(['owner', 'adopted'])
})
it('rejects cleanup-time registration while a restart is unloading', async () => {
const ctx = new Context()
let registrationError: unknown