How to use the @posva/vuefire-test-helpers.createOps 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 / options.spec.ts View on Github external
describe('options', () => {
  let collection: firestore.CollectionReference,
    document: firestore.DocumentReference,
    vm: Record,
    resolve: (data: any) => void,
    reject: (error: any) => void
  const ops = createOps()

  beforeEach(async () => {
    // @ts-ignore
    collection = db.collection()
    // @ts-ignore
    document = collection.doc()
    vm = {}
    await document.update({ foo: 'foo' })
  })

  it('allows customizing serialize when calling bindDocument', async () => {
    const spy = jest.fn(() => ({ bar: 'foo' }))
    await new Promise((res, rej) => {
      resolve = jest.fn(res)
      reject = jest.fn(rej)
      bindDocument({ vm, key: 'foo', document, resolve, reject, ops }, { serialize: spy })
github vuejs / vuefire / packages / @posva / vuefire-core / __tests__ / firestore / collection.spec.ts View on Github external
beforeEach(async () => {
    // @ts-ignore
    collection = db.collection()
    vm = {}
    ops = createOps()
    await new Promise((res, rej) => {
      resolve = jest.fn(res)
      reject = jest.fn(rej)
      unbind = bindCollection({ vm, key: 'items', collection, 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) => {
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-collections.spec.ts View on Github external
beforeEach(async () => {
    vm = {
      items: null,
      a: null,
      b: null,
      c: null,
    }
    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__ / rtdb / options.spec.ts View on Github external
describe('RTDB options', () => {
  let collection: MockedReference,
    document: MockedReference,
    vm: Record,
    unbind: () => void
  const ops = createOps()
  beforeEach(async () => {
    collection = new MockFirebase().child('data')
    document = new MockFirebase().child('data')
    vm = {}
  })

  afterEach(() => {
    unbind && unbind()
  })

  it('allows customizing serialize when calling bindDocument', async () => {
    const spy = jest.fn(() => ({ bar: 'foo' }))
    await new Promise((resolve, reject) => {
      unbind = rtdbBindAsObject(
        {
          vm,
github vuejs / vuefire / packages / @posva / vuefire-core / __tests__ / rtdb / as-array.spec.ts View on Github external
describe('RTDB collection', () => {
  let collection: MockedReference,
    vm: Record,
    resolve: (data: any) => void,
    reject: (error: any) => void,
    unbind: ReturnType
  const ops = createOps()

  beforeEach(async () => {
    collection = new MockFirebase().child('data')
    vm = {}
    await new Promise((res, rej) => {
      resolve = jest.fn(res)
      reject = jest.fn(rej)
      unbind = rtdbBindAsArray({
        vm,
        key: 'items',
        collection,
        resolve,
        reject,
        ops,
      })
      collection.flush()
github vuejs / vuefire / packages / @posva / vuefire-core / __tests__ / rtdb / as-object.spec.ts View on Github external
describe('RTDB document', () => {
  let document: MockedReference,
    vm: Record,
    resolve: (data: any) => void,
    reject: (error: any) => void,
    unbind: () => void
  const ops = createOps()

  beforeEach(async () => {
    document = new MockFirebase().child('data')
    vm = {}
    await new Promise((res, rej) => {
      resolve = jest.fn(res)
      reject = jest.fn(rej)
      unbind = rtdbBindAsObject({
        vm,
        key: 'item',
        document,
        resolve,
        reject,
        ops,
      })
      document.flush()