1
- import { rtdbPlugin } from '../../src'
2
- import { MockFirebase , Vue } from '@posva/vuefire-test-helpers'
3
-
4
- Vue . use ( rtdbPlugin )
1
+ import { mount } from '@vue/test-utils'
2
+ import { rtdbPlugin } from '../../../src'
3
+ import { MockFirebase } from '../../src'
5
4
6
5
function createMixins ( ) {
7
6
const db = new MockFirebase ( ) . child ( 'data' )
@@ -46,12 +45,21 @@ function createMixins() {
46
45
return { mWithFn, mWithObjA, mWithObjB, docs }
47
46
}
48
47
48
+ const global = {
49
+ plugins : [ rtdbPlugin ] ,
50
+ }
51
+
49
52
describe ( 'RTDB: merging' , ( ) => {
50
53
it . skip ( 'should merge properties' , ( ) => {
51
54
const { mWithObjA, mWithObjB, docs } = createMixins ( )
52
- const vm = new Vue ( {
53
- mixins : [ mWithObjA , mWithObjB ] ,
54
- } )
55
+ const { vm } = mount (
56
+ {
57
+ template : 'no' ,
58
+ // @ts -ignore
59
+ mixins : [ mWithObjA , mWithObjB ] ,
60
+ } ,
61
+ { global }
62
+ )
55
63
expect ( Object . keys ( vm . $firebaseRefs ) ) . toEqual ( [ 'a' , 'b' , 'c' ] )
56
64
expect ( vm . $firebaseRefs ) . toEqual ( {
57
65
a : docs [ 2 ] ,
@@ -62,9 +70,13 @@ describe('RTDB: merging', () => {
62
70
63
71
it ( 'supports function syntax' , ( ) => {
64
72
const { docs, mWithFn } = createMixins ( )
65
- const vm = new Vue ( {
66
- mixins : [ mWithFn ] ,
67
- } )
73
+ const { vm } = mount (
74
+ {
75
+ template : 'no' ,
76
+ mixins : [ mWithFn ] ,
77
+ } ,
78
+ { global }
79
+ )
68
80
expect ( vm . $firebaseRefs ) . toEqual ( {
69
81
a : docs [ 4 ] ,
70
82
c : docs [ 5 ] ,
@@ -73,24 +85,18 @@ describe('RTDB: merging', () => {
73
85
74
86
it . skip ( 'should merge two functions' , ( ) => {
75
87
const { docs, mWithFn, mWithObjA, mWithObjB } = createMixins ( )
76
- const vm = new Vue ( {
77
- mixins : [ mWithObjA , mWithObjB , mWithFn ] ,
78
- } )
88
+ const { vm } = mount (
89
+ {
90
+ template : 'no' ,
91
+ // @ts -ignore
92
+ mixins : [ mWithObjA , mWithObjB , mWithFn ] ,
93
+ } ,
94
+ { global }
95
+ )
79
96
expect ( vm . $firebaseRefs ) . toEqual ( {
80
97
a : docs [ 4 ] ,
81
98
b : docs [ 1 ] ,
82
99
c : docs [ 5 ] ,
83
100
} )
84
101
} )
85
-
86
- it ( 'ignores no return' , ( ) => {
87
- const spy = ( Vue . config . errorHandler = jest . fn ( ) )
88
- // @ts -ignore this line is invalid in ts
89
- new Vue ( {
90
- // @ts -ignore this line is invalid in ts
91
- // firebase: () => {},
92
- } )
93
- expect ( spy ) . not . toHaveBeenCalled ( )
94
- spy . mockRestore ( )
95
- } )
96
102
} )
0 commit comments