How to use the @posva/vuefire-test-helpers.spyOnSnapshot 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
it('unbinds removed properties', async () => {
    // @ts-ignore
    const a: firestore.DocumentReference = db.collection().doc()
    const unbindSpy = spyUnbind(a)
    const callbackSpy = spyOnSnapshotCallback(a)
    const onSnapshotSpy = spyOnSnapshot(a)

    // @ts-ignore
    const item: firestore.DocumentReference = db.collection().doc()
    await a.update({ isA: true })
    await b.update({ isB: true })
    await item.update({ a })

    expect(unbindSpy).toHaveBeenCalledTimes(0)
    expect(callbackSpy).toHaveBeenCalledTimes(0)
    expect(onSnapshotSpy).toHaveBeenCalledTimes(0)
    await bind('item', item)

    expect(unbindSpy).toHaveBeenCalledTimes(0)
    expect(callbackSpy).toHaveBeenCalledTimes(1)
    expect(onSnapshotSpy).toHaveBeenCalledTimes(1)
github vuejs / vuefire / packages / @posva / vuefire-core / __tests__ / firestore / refs-documents.spec.ts View on Github external
it('does not rebind if it is the same ref', async () => {
    const spy = spyOnSnapshot(item)
    await item.update({ baz: 'baz' })
    await d.update({ ref: item })
    // NOTE see #1
    await delay(5)
    expect(spy).toHaveBeenCalledTimes(1)

    await d.update({ ref: item })
    await delay(5)

    expect(spy).toHaveBeenCalledTimes(1)
    spy.mockRestore()
  })