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'
54
65function createMixins ( ) {
76 const db = new MockFirebase ( ) . child ( 'data' )
@@ -46,12 +45,21 @@ function createMixins() {
4645 return { mWithFn, mWithObjA, mWithObjB, docs }
4746}
4847
48+ const global = {
49+ plugins : [ rtdbPlugin ] ,
50+ }
51+
4952describe ( 'RTDB: merging' , ( ) => {
5053 it . skip ( 'should merge properties' , ( ) => {
5154 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+ )
5563 expect ( Object . keys ( vm . $firebaseRefs ) ) . toEqual ( [ 'a' , 'b' , 'c' ] )
5664 expect ( vm . $firebaseRefs ) . toEqual ( {
5765 a : docs [ 2 ] ,
@@ -62,9 +70,13 @@ describe('RTDB: merging', () => {
6270
6371 it ( 'supports function syntax' , ( ) => {
6472 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+ )
6880 expect ( vm . $firebaseRefs ) . toEqual ( {
6981 a : docs [ 4 ] ,
7082 c : docs [ 5 ] ,
@@ -73,24 +85,18 @@ describe('RTDB: merging', () => {
7385
7486 it . skip ( 'should merge two functions' , ( ) => {
7587 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+ )
7996 expect ( vm . $firebaseRefs ) . toEqual ( {
8097 a : docs [ 4 ] ,
8198 b : docs [ 1 ] ,
8299 c : docs [ 5 ] ,
83100 } )
84101 } )
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- } )
96102} )
0 commit comments