File tree 4 files changed +56
-57
lines changed
4 files changed +56
-57
lines changed Original file line number Diff line number Diff line change 1
- export * from './wait-for-update'
1
+ import Vue from 'vue'
2
+
3
+ Vue . config . productionTip = false
4
+ export { Vue }
5
+
2
6
export * from './mock'
7
+
8
+ export function spyUnbind ( ref ) {
9
+ const spy = jest . fn ( )
10
+ const onSnapshot = ref . onSnapshot . bind ( ref )
11
+ ref . onSnapshot = fn => {
12
+ const unbind = onSnapshot ( fn )
13
+ return ( ) => {
14
+ spy ( )
15
+ unbind ( )
16
+ }
17
+ }
18
+ return spy
19
+ }
20
+
21
+ export function spyOnSnapshot ( ref ) {
22
+ const onSnapshot = ref . onSnapshot . bind ( ref )
23
+ return ( ref . onSnapshot = jest . fn ( ( ...args ) => onSnapshot ( ...args ) ) )
24
+ }
25
+
26
+ export function spyOnSnapshotCallback ( ref ) {
27
+ const onSnapshot = ref . onSnapshot . bind ( ref )
28
+ const spy = jest . fn ( )
29
+ ref . onSnapshot = fn => onSnapshot ( ( ...args ) => {
30
+ spy ( )
31
+ fn ( ...args )
32
+ } )
33
+ return spy
34
+ }
35
+
36
+ // This makes sure some tests fail by delaying callbacks
37
+ export function delayUpdate ( ref , time = 0 ) {
38
+ const onSnapshot = ref . onSnapshot . bind ( ref )
39
+ ref . onSnapshot = fn => onSnapshot ( async ( ...args ) => {
40
+ await delay ( time )
41
+ fn ( ...args )
42
+ } )
43
+ }
44
+
45
+ export function tick ( ) {
46
+ return new Promise ( ( resolve , reject ) => {
47
+ Vue . nextTick ( resolve )
48
+ } )
49
+ }
50
+
51
+ export function delay ( time ) {
52
+ return new Promise ( resolve => setTimeout ( resolve , time ) )
53
+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 3
3
db ,
4
4
tick ,
5
5
delay ,
6
+ delayUpdate ,
6
7
Vue
7
8
} from './helpers'
8
9
@@ -26,15 +27,6 @@ beforeEach(async () => {
26
27
await tick ( )
27
28
} )
28
29
29
- // This makes sure some tests fail by delaying callbacks
30
- function delayUpdate ( ref , time = 0 ) {
31
- const onSnapshot = ref . onSnapshot . bind ( ref )
32
- ref . onSnapshot = fn => onSnapshot ( async ( ...args ) => {
33
- await delay ( time )
34
- fn ( ...args )
35
- } )
36
- }
37
-
38
30
test ( 'binds refs on collections' , async ( ) => {
39
31
await vm . $bind ( 'items' , collection )
40
32
Original file line number Diff line number Diff line change 3
3
db ,
4
4
tick ,
5
5
delay ,
6
+ spyUnbind ,
7
+ spyOnSnapshot ,
8
+ spyOnSnapshotCallback ,
6
9
Vue
7
10
} from './helpers'
8
11
@@ -40,34 +43,6 @@ beforeEach(async () => {
40
43
await delay ( 5 )
41
44
} )
42
45
43
- function spyUnbind ( ref ) {
44
- const spy = jest . fn ( )
45
- const onSnapshot = ref . onSnapshot . bind ( ref )
46
- ref . onSnapshot = fn => {
47
- const unbind = onSnapshot ( fn )
48
- return ( ) => {
49
- spy ( )
50
- unbind ( )
51
- }
52
- }
53
- return spy
54
- }
55
-
56
- function spyOnSnapshot ( ref ) {
57
- const onSnapshot = ref . onSnapshot . bind ( ref )
58
- return ( ref . onSnapshot = jest . fn ( ( ...args ) => onSnapshot ( ...args ) ) )
59
- }
60
-
61
- function spyOnSnapshotCallback ( ref ) {
62
- const onSnapshot = ref . onSnapshot . bind ( ref )
63
- const spy = jest . fn ( )
64
- ref . onSnapshot = fn => onSnapshot ( ( ...args ) => {
65
- spy ( )
66
- fn ( ...args )
67
- } )
68
- return spy
69
- }
70
-
71
46
test ( 'binds refs on documents' , async ( ) => {
72
47
// create an empty doc and update using the ref instead of plain data
73
48
const c = collection . doc ( )
You can’t perform that action at this time.
0 commit comments