-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.test.js
58 lines (50 loc) · 1.21 KB
/
index.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
const Vue = require('vue')
const VueStyletron = require('./index')
beforeAll(() => {
Vue.use(VueStyletron)
})
it('install mixin', () => {
expect(Vue.options.created.length).toBe(1)
})
it('install directive', () => {
expect(Vue.options.directives.style).toBeTruthy()
})
it("creates classes and store them in component's data", () => {
const instance = {
style: {
test: {
color: 'red'
}
}
}
VueStyletron.mixin.created.call(instance)
expect(instance).toHaveProperty('$style.test')
})
it('applies classes to element', () => {
const el = { className: 'test' }
const bindings = { expression: 'el' }
const vnode = { context: { $style: { el: 'class-1 class-2' } } }
VueStyletron.directive(el, bindings, vnode)
expect(el.className).toBe('test class-1 class-2')
})
/*
it('creates classes and applies them on a component', () => {
const el = document.createElement('div')
return new Vue({
el,
data: {
style: {
el: {
color: 'red'
}
}
},
render (createElement) {
return createElement('div', { 'v-style': 'el' })
}
})
.$nextTick(function() {
// expect(this.$el.classList.contains(cls)).toBe(true)
})
})
*/