1
- import { firestorePlugin } from '../../../src'
2
- import { db } from '../../src'
3
- import { mount } from '@vue/test-utils'
4
- import * as firestore from '@firebase/firestore-types'
5
1
import { defineComponent } from 'vue'
2
+ import { mount } from '@vue/test-utils'
3
+ import { describe , expect , it , vi } from 'vitest'
4
+ import { firestorePlugin , PluginOptions , useCollection } from '../../src'
5
+ import { addDoc , DocumentData } from 'firebase/firestore'
6
+ import { expectType , setupFirestoreRefs , tds , firestore } from '../utils'
7
+ import { usePendingPromises } from '../../src/vuefire/firestore'
8
+ import { type Ref } from 'vue'
6
9
7
10
const component = defineComponent ( { template : 'no' } )
8
11
9
- describe ( 'Firestore: plugin options' , ( ) => {
12
+ describe . skip ( 'Firestore: Options API' , ( ) => {
13
+ const { itemRef, listRef, orderedListRef, collection, doc } =
14
+ setupFirestoreRefs ( )
15
+
10
16
it ( 'allows customizing $rtdbBind' , ( ) => {
11
17
const wrapper = mount ( component , {
12
18
global : {
@@ -21,13 +27,16 @@ describe('Firestore: plugin options', () => {
21
27
] ,
22
28
} ,
23
29
} )
24
- expect ( typeof ( wrapper . vm as any ) . $myBind ) . toBe ( 'function' )
25
- expect ( typeof ( wrapper . vm as any ) . $myUnbind ) . toBe ( 'function' )
30
+
31
+ // @ts -expect-error: haven't extended the types
32
+ expect ( wrapper . vm . $myBind ) . toBeTypeOf ( 'function' )
33
+ // @ts -expect-error: haven't extended the types
34
+ expect ( wrapper . vm . $myUnbind ) . toBeTypeOf ( 'function' )
26
35
} )
27
36
28
37
it ( 'calls custom serialize function with collection' , async ( ) => {
29
- const pluginOptions = {
30
- serialize : jest . fn ( ( ) => ( { foo : 'bar' } ) ) ,
38
+ const pluginOptions : PluginOptions = {
39
+ serialize : vi . fn ( ( ) => ( { foo : 'bar' } ) ) ,
31
40
}
32
41
const wrapper = mount (
33
42
{
@@ -41,8 +50,7 @@ describe('Firestore: plugin options', () => {
41
50
}
42
51
)
43
52
44
- // @ts -ignore
45
- const items : firestore . CollectionReference = db . collection ( )
53
+ const items = collection ( )
46
54
await items . add ( { } )
47
55
48
56
await wrapper . vm . $bind ( 'items' , items )
@@ -57,7 +65,7 @@ describe('Firestore: plugin options', () => {
57
65
58
66
it ( 'can be overridden by local option' , async ( ) => {
59
67
const pluginOptions = {
60
- serialize : jest . fn ( ( ) => ( { foo : 'bar' } ) ) ,
68
+ serialize : vi . fn ( ( ) => ( { foo : 'bar' } ) ) ,
61
69
}
62
70
const wrapper = mount (
63
71
{
@@ -75,7 +83,7 @@ describe('Firestore: plugin options', () => {
75
83
const items : firestore . CollectionReference = db . collection ( )
76
84
await items . add ( { } )
77
85
78
- const spy = jest . fn ( ( ) => ( { bar : 'bar' } ) )
86
+ const spy = vi . fn ( ( ) => ( { bar : 'bar' } ) )
79
87
80
88
await wrapper . vm . $bind ( 'items' , items , { serialize : spy } )
81
89
0 commit comments