Skip to content

Commit 6114c68

Browse files
committed
test(refs): unbinds when a ref is replaced
1 parent 600fe7b commit 6114c68

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

test/refs.spec.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,3 +239,35 @@ test('unbinds multiple refs when the document is unbound', async () => {
239239
cSpy.mockRestore()
240240
dSpy.mockRestore()
241241
})
242+
243+
test('unbinds when a ref is replaced', async () => {
244+
const aSpy = spyUnbind(a)
245+
const cSpy = spyUnbind(c)
246+
const dSpy = spyUnbind(d)
247+
248+
await a.update({ a: true })
249+
250+
await vm.$bind('d', d)
251+
expect(vm.d).toEqual({
252+
ref: {
253+
c: true
254+
}
255+
})
256+
257+
await d.update({ ref: a })
258+
// wait for nested ref update
259+
await delay(5)
260+
expect(vm.d).toEqual({
261+
ref: {
262+
a: true
263+
}
264+
})
265+
266+
// expect(dSpy.mock.calls.length).toBe(1)
267+
expect(cSpy.mock.calls.length).toBe(1)
268+
expect(aSpy.mock.calls.length).toBe(0)
269+
270+
aSpy.mockRestore()
271+
cSpy.mockRestore()
272+
dSpy.mockRestore()
273+
})

0 commit comments

Comments
 (0)