How to use the @posva/vuefire-test-helpers.delay function in @posva/vuefire-test-helpers

To help you get started, we’ve selected a few @posva/vuefire-test-helpers examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vuejs / vuefire / packages / @posva / vuefire-core / __tests__ / firestore / refs-documents.spec.ts View on Github external
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()
  })
github vuejs / vuefire / packages / @posva / vuefire-core / __tests__ / firestore / refs-collections.spec.ts View on Github external
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 } }])
  })