Completed
Push — master ( d7c134...17f83b )
by Taavo-Taur
54s
created

test/helpers/before/vue-hookup.js   A

Complexity

Total Complexity 6
Complexity/F 1.5

Size

Lines of Code 38
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 0
c 3
b 0
f 0
nc 1
dl 0
loc 38
rs 10
noi 0
wmc 6
mnd 1
bc 6
fnc 4
bpm 1.5
cpm 1.5

3 Functions

Rating   Name   Duplication   Size   Complexity  
A vue-hookup.js ➔ addVueWithPlugin 0 18 1
A BaseVue.config.errorHandler 0 5 1
A vue-hookup.js ➔ vueCleanup 0 9 3
1
import BaseVue from 'vue'
2
import VueSyncersFeathers from '../../../src'
3
4
// If a vue error happens log extra info on the error
5
BaseVue.config.errorHandler = function (err, vm) {
6
	const t = Object.getPrototypeOf(vm).constructor.test
7
	console.log('Test: ', t._test.title)
8
	console.error(err)
9
}
10
11
export function addVueWithPlugin(t, options) {
12
	const Vue = t.context.Vue = BaseVue.extend()
13
14
	// Because we're installing onto extended vue instance copy global methods to new instance
15
	Vue.version = BaseVue.version
16
	Vue.util = BaseVue.util
17
	Vue.set = BaseVue.set
18
	Vue.delete = BaseVue.delete
19
	Vue.nextTick = BaseVue.nextTick
20
	Vue.config = BaseVue.config // Not cloned
21
	Vue.test = t
22
	// To reference the right Vue instance
23
	Vue.mixin = function (mixin) {
24
		Vue.options = Vue.util.mergeOptions(Vue.options, mixin)
25
	}
26
27
	BaseVue.use.call(Vue, {install: VueSyncersFeathers.install}, options)
28
}
29
30
export function vueCleanup(t) {
31
	if (t.context.instance) {
32
		t.context.instance.$destroy()
33
		delete t.context.instance
34
	}
35
	if (t.context.Vue) {
36
		delete t.context.Vue
37
	}
38
}
39