How to use the @posva/vuefire-test-helpers.MockFirebase 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__ / rtdb / bind.spec.ts View on Github external
it('can customize the reset option through $rtdbBind', async () => {
    const { vm, source } = await createVm()
    const otherSource = new MockFirebase().child('data2')
    source.set({ name: 'foo' })
    otherSource.set({ name: 'bar' })
    let p = vm.$rtdbBind('item', source)
    source.flush()
    await p
    p = vm.$rtdbBind('item', otherSource, { reset: false })
    expect(vm.item).toEqual({ name: 'foo' })
    otherSource.flush()
    await p
    expect(vm.item).toEqual({ name: 'bar' })
    // should not apply last used option
    p = vm.$rtdbBind('item', source)
    expect(vm.item).toEqual(null)
    source.flush()
  })
github vuejs / vuefire / packages / vuexfire / __tests__ / rtdb.spec.ts View on Github external
import Vuex from 'vuex'
import { firebaseAction, vuexfireMutations } from '../src'
import { MockFirebase, tick, Vue } from '@posva/vuefire-test-helpers'
import { database } from 'firebase'
import { RTDBOptions } from '@posva/vuefire-core/dist/packages/@posva/vuefire-core/src'

Vue.use(Vuex)

const db = new MockFirebase().child('data')

describe('RTDB: firebaseAction', () => {
  const item: any = null,
    items: any[] = []
  const store = new Vuex.Store<{ item: any; items: any[] }>({
    state: { items, item },
    mutations: vuexfireMutations,
    actions: {
      action: firebaseAction((context, fn) => fn(context)),
    },

    modules: {
      module: {
        namespaced: true,
        actions: {
          action: firebaseAction((context, fn) => fn(context)),
github vuejs / vuefire / packages / @posva / vuefire-core / __tests__ / rtdb / as-array.spec.ts View on Github external
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 / options.spec.ts View on Github external
beforeEach(async () => {
    collection = new MockFirebase().child('data')
    document = new MockFirebase().child('data')
    vm = {}
  })
github vuejs / vuefire / packages / @posva / vuefire-core / __tests__ / rtdb / as-object.spec.ts View on Github external
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()
    })
  })