Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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()
})
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)),
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()
})
})
beforeEach(async () => {
collection = new MockFirebase().child('data')
document = new MockFirebase().child('data')
vm = {}
})
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()
})
})