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