@@ -5,11 +5,12 @@ import {
55} from '../../../src/core'
66import { db , createOps } from '../../src'
77import { firestore } from 'firebase'
8+ import { Ref , ref } from 'vue'
89
910describe ( 'options' , ( ) => {
1011 let collection : firestore . CollectionReference ,
1112 document : firestore . DocumentReference ,
12- vm : Record < string , any > ,
13+ target : Ref < Record < string , any > > ,
1314 resolve : ( data : any ) => void ,
1415 reject : ( error : any ) => void
1516 const ops = createOps ( )
@@ -19,7 +20,7 @@ describe('options', () => {
1920 collection = db . collection ( )
2021 // @ts -ignore
2122 document = collection . doc ( )
22- vm = { }
23+ target = ref ( { } )
2324 await document . update ( { foo : 'foo' } )
2425 } )
2526
@@ -29,15 +30,15 @@ describe('options', () => {
2930 resolve = jest . fn ( res )
3031 reject = jest . fn ( rej )
3132 bindDocument (
32- { vm , key : 'foo' , document, resolve, reject, ops } ,
33+ { target , document, resolve, reject, ops } ,
3334 { serialize : spy }
3435 )
3536 } )
3637 expect ( spy ) . toHaveBeenCalledTimes ( 1 )
3738 expect ( spy ) . toBeCalledWith (
3839 expect . objectContaining ( { data : expect . any ( Function ) } )
3940 )
40- expect ( vm . foo ) . toEqual ( { bar : 'foo' } )
41+ expect ( target . value ) . toEqual ( { bar : 'foo' } )
4142 } )
4243
4344 it ( 'allows customizing serialize when calling bindCollection' , async ( ) => {
@@ -46,15 +47,15 @@ describe('options', () => {
4647 resolve = jest . fn ( res )
4748 reject = jest . fn ( rej )
4849 bindCollection (
49- { vm , key : 'foo' , collection, resolve, reject, ops } ,
50+ { target , collection, resolve, reject, ops } ,
5051 { serialize : spy }
5152 )
5253 } )
5354 expect ( spy ) . toHaveBeenCalledTimes ( 1 )
5455 expect ( spy ) . toBeCalledWith (
5556 expect . objectContaining ( { data : expect . any ( Function ) } )
5657 )
57- expect ( vm . foo ) . toEqual ( [ { bar : 'foo' } ] )
58+ expect ( target . value ) . toEqual ( [ { bar : 'foo' } ] )
5859 } )
5960
6061 it ( 'can set options globally for bindDocument' , async ( ) => {
@@ -64,13 +65,13 @@ describe('options', () => {
6465 await new Promise ( ( res , rej ) => {
6566 resolve = jest . fn ( res )
6667 reject = jest . fn ( rej )
67- bindDocument ( { vm , key : 'foo' , document, resolve, reject, ops } )
68+ bindDocument ( { target , document, resolve, reject, ops } )
6869 } )
6970 expect ( spy ) . toHaveBeenCalledTimes ( 1 )
7071 expect ( spy ) . toBeCalledWith (
7172 expect . objectContaining ( { data : expect . any ( Function ) } )
7273 )
73- expect ( vm . foo ) . toEqual ( { bar : 'foo' } )
74+ expect ( target . value ) . toEqual ( { bar : 'foo' } )
7475 // restore it
7576 firestoreOptions . serialize = serialize
7677 } )
@@ -82,13 +83,13 @@ describe('options', () => {
8283 await new Promise ( ( res , rej ) => {
8384 resolve = jest . fn ( res )
8485 reject = jest . fn ( rej )
85- bindCollection ( { vm , key : 'foo' , collection, resolve, reject, ops } )
86+ bindCollection ( { target , collection, resolve, reject, ops } )
8687 } )
8788 expect ( spy ) . toHaveBeenCalledTimes ( 1 )
8889 expect ( spy ) . toBeCalledWith (
8990 expect . objectContaining ( { data : expect . any ( Function ) } )
9091 )
91- expect ( vm . foo ) . toEqual ( [ { bar : 'foo' } ] )
92+ expect ( target . value ) . toEqual ( [ { bar : 'foo' } ] )
9293 // restore it
9394 firestoreOptions . serialize = serialize
9495 } )
0 commit comments