1
1
import { firestorePlugin } from '../../src'
2
2
import { db , tick , delayUpdate , Vue } from '@posva/vuefire-test-helpers'
3
- import { firestore } from 'firebase'
3
+ import firebase from 'firebase/app '
4
4
import { CombinedVueInstance } from 'vue/types/vue'
5
5
6
6
Vue . use ( firestorePlugin )
7
7
8
8
describe ( 'Firestore: binding' , ( ) => {
9
- let collection : firestore . CollectionReference ,
10
- document : firestore . DocumentReference ,
9
+ let collection : firebase . firestore . CollectionReference ,
10
+ document : firebase . firestore . DocumentReference ,
11
11
vm : CombinedVueInstance < Vue , { items : any [ ] ; item : any } , object , object , Record < never , any > >
12
12
beforeEach ( async ( ) => {
13
13
// @ts -ignore
@@ -59,7 +59,7 @@ describe('Firestore: binding', () => {
59
59
it ( 'unbinds previously bound refs' , async ( ) => {
60
60
await document . update ( { foo : 'foo' } )
61
61
// @ts -ignore
62
- const doc2 : firestore . DocumentReference = db . collection ( ) . doc ( )
62
+ const doc2 : firebase . firestore . DocumentReference = db . collection ( ) . doc ( )
63
63
await doc2 . update ( { bar : 'bar' } )
64
64
await vm . $bind ( 'item' , document )
65
65
expect ( vm . $firestoreRefs . item ) . toBe ( document )
@@ -74,7 +74,7 @@ describe('Firestore: binding', () => {
74
74
it ( 'waits for all refs in document' , async ( ) => {
75
75
const a = db . collection ( ) . doc ( )
76
76
// @ts -ignore
77
- const b : firestore . DocumentReference = db . collection ( ) . doc ( )
77
+ const b : firebase . firestore . DocumentReference = db . collection ( ) . doc ( )
78
78
delayUpdate ( b )
79
79
await document . update ( { a, b } )
80
80
@@ -89,7 +89,7 @@ describe('Firestore: binding', () => {
89
89
test ( 'waits for all refs in document with interrupting by new ref' , async ( ) => {
90
90
const a = db . collection ( ) . doc ( )
91
91
// @ts -ignore
92
- const b : firestore . DocumentReference = db . collection ( ) . doc ( )
92
+ const b : firebase . firestore . DocumentReference = db . collection ( ) . doc ( )
93
93
const c = db . collection ( ) . doc ( )
94
94
delayUpdate ( b )
95
95
await document . update ( { a, b } )
@@ -110,7 +110,7 @@ describe('Firestore: binding', () => {
110
110
it ( 'waits for all refs in collection' , async ( ) => {
111
111
const a = db . collection ( ) . doc ( )
112
112
// @ts -ignore
113
- const b : firestore . DocumentReference = db . collection ( ) . doc ( )
113
+ const b : firebase . firestore . DocumentReference = db . collection ( ) . doc ( )
114
114
delayUpdate ( b )
115
115
await collection . add ( { a } )
116
116
await collection . add ( { b } )
@@ -123,9 +123,9 @@ describe('Firestore: binding', () => {
123
123
it ( 'waits for nested refs in document' , async ( ) => {
124
124
const a = db . collection ( ) . doc ( )
125
125
// @ts -ignore
126
- const b : firestore . DocumentReference = db . collection ( ) . doc ( )
126
+ const b : firebase . firestore . DocumentReference = db . collection ( ) . doc ( )
127
127
// @ts -ignore
128
- const c : firestore . DocumentReference = db . collection ( ) . doc ( )
128
+ const c : firebase . firestore . DocumentReference = db . collection ( ) . doc ( )
129
129
await b . update ( { c } )
130
130
delayUpdate ( b )
131
131
delayUpdate ( c , 5 )
@@ -142,9 +142,9 @@ describe('Firestore: binding', () => {
142
142
it ( 'waits for nested refs with data in document' , async ( ) => {
143
143
const a = db . collection ( ) . doc ( )
144
144
// @ts -ignore
145
- const b : firestore . DocumentReference = db . collection ( ) . doc ( )
145
+ const b : firebase . firestore . DocumentReference = db . collection ( ) . doc ( )
146
146
// @ts -ignore
147
- const c : firestore . DocumentReference = db . collection ( ) . doc ( )
147
+ const c : firebase . firestore . DocumentReference = db . collection ( ) . doc ( )
148
148
await a . update ( { isA : true } )
149
149
await c . update ( { isC : true } )
150
150
await b . update ( { c } )
@@ -163,9 +163,9 @@ describe('Firestore: binding', () => {
163
163
it ( 'waits for nested refs in collections' , async ( ) => {
164
164
const a = db . collection ( ) . doc ( )
165
165
// @ts -ignore
166
- const b : firestore . DocumentReference = db . collection ( ) . doc ( )
166
+ const b : firebase . firestore . DocumentReference = db . collection ( ) . doc ( )
167
167
// @ts -ignore
168
- const c : firestore . DocumentReference = db . collection ( ) . doc ( )
168
+ const c : firebase . firestore . DocumentReference = db . collection ( ) . doc ( )
169
169
await b . update ( { c } )
170
170
delayUpdate ( b )
171
171
delayUpdate ( c , 5 )
@@ -180,9 +180,9 @@ describe('Firestore: binding', () => {
180
180
it ( 'waits for nested refs with data in collections' , async ( ) => {
181
181
const a = db . collection ( ) . doc ( )
182
182
// @ts -ignore
183
- const b : firestore . DocumentReference = db . collection ( ) . doc ( )
183
+ const b : firebase . firestore . DocumentReference = db . collection ( ) . doc ( )
184
184
// @ts -ignore
185
- const c : firestore . DocumentReference = db . collection ( ) . doc ( )
185
+ const c : firebase . firestore . DocumentReference = db . collection ( ) . doc ( )
186
186
await a . update ( { isA : true } )
187
187
await c . update ( { isC : true } )
188
188
await b . update ( { c } )
@@ -199,7 +199,7 @@ describe('Firestore: binding', () => {
199
199
it ( 'can customize the reset option through $bind' , async ( ) => {
200
200
await document . update ( { foo : 'foo' } )
201
201
// @ts -ignore
202
- const doc2 : firestore . DocumentReference = db . collection ( ) . doc ( )
202
+ const doc2 : firebase . firestore . DocumentReference = db . collection ( ) . doc ( )
203
203
await doc2 . update ( { bar : 'bar' } )
204
204
await vm . $bind ( 'item' , document )
205
205
expect ( vm . item ) . toEqual ( { foo : 'foo' } )
@@ -214,7 +214,7 @@ describe('Firestore: binding', () => {
214
214
it ( 'can customize the reset option through $unbind' , async ( ) => {
215
215
await document . update ( { foo : 'foo' } )
216
216
// @ts -ignore
217
- const doc2 : firestore . DocumentReference = db . collection ( ) . doc ( )
217
+ const doc2 : firebase . firestore . DocumentReference = db . collection ( ) . doc ( )
218
218
await doc2 . update ( { bar : 'bar' } )
219
219
await vm . $bind ( 'item' , document )
220
220
vm . $unbind ( 'item' , false )
@@ -229,7 +229,7 @@ describe('Firestore: binding', () => {
229
229
await collection . add ( { foo : 'foo' } )
230
230
await vm . $bind ( 'items' , collection )
231
231
// @ts -ignore
232
- const col2 : firestore . CollectionReference = db . collection ( )
232
+ const col2 : firebase . firestore . CollectionReference = db . collection ( )
233
233
await col2 . add ( { bar : 'bar' } )
234
234
const p = vm . $bind ( 'items' , col2 , { wait : true , reset : true } )
235
235
expect ( vm . items ) . toEqual ( [ { foo : 'foo' } ] )
@@ -241,7 +241,7 @@ describe('Firestore: binding', () => {
241
241
await collection . add ( { foo : 'foo' } )
242
242
await vm . $bind ( 'items' , collection )
243
243
// @ts -ignore
244
- const col2 : firestore . CollectionReference = db . collection ( )
244
+ const col2 : firebase . firestore . CollectionReference = db . collection ( )
245
245
await col2 . add ( { bar : 'bar' } )
246
246
const p = vm . $bind ( 'items' , col2 , { wait : true , reset : ( ) => [ 'foo' ] } )
247
247
expect ( vm . items ) . toEqual ( [ 'foo' ] )
0 commit comments