How to use the @posva/vuefire-test-helpers.db.collection 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 / vuefire / __tests__ / firestore / bind.spec.ts View on Github external
it('wait + reset can be overriden with a function', async () => {
    await collection.add({ foo: 'foo' })
    await vm.$bind('items', collection)
    // @ts-ignore
    const col2: firestore.CollectionReference = db.collection()
    await col2.add({ bar: 'bar' })
    const p = vm.$bind('items', col2, { wait: true, reset: () => ['foo'] })
    expect(vm.items).toEqual(['foo'])
    await p
    expect(vm.items).toEqual([{ bar: 'bar' }])
  })
})
github vuejs / vuefire / packages / vuefire / __tests__ / firestore / bind.spec.ts View on Github external
it('waits for nested refs in document', async () => {
    const a = db.collection().doc()
    // @ts-ignore
    const b: firestore.DocumentReference = db.collection().doc()
    // @ts-ignore
    const c: firestore.DocumentReference = db.collection().doc()
    await b.update({ c })
    delayUpdate(b)
    delayUpdate(c, 5)
    await document.update({ a, b })

    await vm.$bind('item', document)

    expect(vm.item).toEqual({
      a: null,
      b: { c: null },
    })
  })
github vuejs / vuefire / packages / vuexfire / __tests__ / firestore.spec.ts View on Github external
it('wait + reset can be overriden with a function', async () => {
    // @ts-ignore
    const col2: firestore.CollectionReference = db.collection()
    await setItems(collection)
    await collection.add({ text: 'foo' })
    const p = setItems(col2, { wait: true, reset: () => ['foo'] })
    expect(store.state.items).toEqual(['foo'])
    await p
    expect(store.state.items).toEqual([])
  })
})
github vuejs / vuefire / packages / @posva / vuefire-core / __tests__ / firestore / refs-collections.spec.ts View on Github external
it('respects provided maxRefDepth', async () => {
    const a = db.collection().doc()
    const b = db.collection().doc()
    const c = db.collection().doc()
    const d = db.collection().doc()
    await a.set({ b })
    await b.set({ c })
    await d.set({ isD: true })
    await c.set({ d })
    const collection = db.collection()
    await collection.add({ a })

    // @ts-ignore
    await bind('items', collection, { maxRefDepth: 1 })
    expect(vm.items).toEqual([
      {
        a: {
          b: b.path,
        },
      },
    ])

    // @ts-ignore
    await bind('items', collection, { maxRefDepth: 3 })
    expect(vm.items).toEqual([
      {
github vuejs / vuefire / packages / @posva / vuefire-core / __tests__ / firestore / refs-collections.spec.ts View on Github external
}
    ops = createOps()
    bind = (key, collection, options) => {
      return new Promise(
        (resolve, reject) =>
          (unbind = bindCollection({ vm, key, collection, resolve, reject, ops }, options))
      )
    }
    // @ts-ignore
    a = db.collection().doc()
    // @ts-ignore
    b = db.collection().doc()
    await a.update({ isA: true })
    await b.update({ isB: true })
    // @ts-ignore
    collection = db.collection()
    first = await collection.add({ ref: a })
    await collection.add({ ref: b })
  })
github vuejs / vuefire / packages / @posva / vuefire-core / __tests__ / firestore / refs-documents.spec.ts View on Github external
beforeEach(async () => {
    vm = {
      item: null,
      a: null,
      b: null,
      c: null,
    }
    ops = createOps()
    // @ts-ignore
    collection = db.collection()
    // @ts-ignore
    a = db.collection().doc()
    // @ts-ignore
    b = db.collection().doc()
    // @ts-ignore
    empty = db.collection().doc()
    // @ts-ignore
    item = db.collection().doc()
    c = collection.doc()
    d = collection.doc()
    await a.update({ isA: true })
    await c.update({ isC: true })
    await d.update({ ref: c })
    bind = (key, document, options) => {
      return new Promise(
        (resolve, reject) =>
github vuejs / vuefire / packages / vuexfire / __tests__ / firestore.spec.ts View on Github external
beforeEach(async () => {
    store.replaceState({
      // @ts-ignore
      items: null,
      item: null,
      module: {
        items: [],
      },
    })

    // @ts-ignore
    collection = db.collection()
    // @ts-ignore
    document = db.collection().doc()
    await tick()
  })
github vuejs / vuefire / packages / @posva / vuefire-core / __tests__ / firestore / document.spec.ts View on Github external
beforeEach(async () => {
    // @ts-ignore
    collection = db.collection()
    // @ts-ignore
    document = collection.doc()
    ops = createOps()
    vm = {}
    await new Promise((res, rej) => {
      resolve = jest.fn(res)
      reject = jest.fn(rej)
      bindDocument({ vm, key: 'item', document, resolve, reject, ops })
    })
  })
github vuejs / vuefire / packages / @posva / vuefire-core / __tests__ / firestore / refs-documents.spec.ts View on Github external
beforeEach(async () => {
    vm = {
      item: null,
      a: null,
      b: null,
      c: null,
    }
    ops = createOps()
    // @ts-ignore
    collection = db.collection()
    // @ts-ignore
    a = db.collection().doc()
    // @ts-ignore
    b = db.collection().doc()
    // @ts-ignore
    empty = db.collection().doc()
    // @ts-ignore
    item = db.collection().doc()
    c = collection.doc()
    d = collection.doc()
    await a.update({ isA: true })
    await c.update({ isC: true })
    await d.update({ ref: c })
    bind = (key, document, options) => {
      return new Promise(
        (resolve, reject) =>
          (unbind = bindDocument({ vm, key, document, resolve, reject, ops }, options))
      )
    }

    await Promise.all([bind('c', c), bind('d', d)])
github vuejs / vuefire / packages / vuexfire / __tests__ / options.spec.ts View on Github external
beforeEach(async () => {
    store.replaceState({
      // @ts-ignore
      items: null,
      item: null,
      module: {
        items: [],
      },
    })

    // @ts-ignore
    collection = db.collection()
    // @ts-ignore
    document = db.collection().doc()
    await tick()
  })