Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const spy = spyOnSnapshotCallback(item)
await item.update({ baz: 'baz' })
await d.update({ ref: item })
// NOTE see #1
await delay(5)
expect(spy).toHaveBeenCalledTimes(1)
await item.update({ baz: 'bar' })
// make sure things are updating correctly
expect(vm.d).toEqual({
ref: { baz: 'bar' },
})
// we call update twice to make sure our mock works
expect(spy).toHaveBeenCalledTimes(2)
await d.update({ ref: b })
// NOTE see #1
await delay(5)
expect(vm.d).toEqual({
ref: null,
})
await item.update({ foo: 'bar' })
expect(spy).toHaveBeenCalledTimes(2)
expect(vm.d).toEqual({
ref: null,
})
spy.mockRestore()
})
it('updates when modifying an item', async () => {
await bind('items', collection)
await first.update({ newThing: true })
await delay(5)
expect(vm.items).toEqual([{ ref: { isA: true }, newThing: true }, { ref: { isB: true } }])
})