@@ -26,6 +26,8 @@ describe('v-b-modal directive', () => {
26
26
27
27
expect(wrapper.isVueInstance()).toBe(true)
28
28
expect(wrapper.is('button')).toBe(true)
29
+
expect(wrapper.find('button').attributes('tabindex')).not.toBeDefined()
30
+
expect(wrapper.find('button').attributes('role')).not.toBeDefined()
29
31
expect(spy).not.toHaveBeenCalled()
30
32
31
33
const $button = wrapper.find('button')
@@ -36,6 +38,48 @@ describe('v-b-modal directive', () => {
36
38
wrapper.destroy()
37
39
})
38
40
41
+
it('works on links', async () => {
42
+
const localVue = new CreateLocalVue()
43
+
const spy = jest.fn()
44
+
45
+
const App = localVue.extend({
46
+
directives: {
47
+
bModal: VBModal
48
+
},
49
+
data() {
50
+
return {
51
+
text: 'link'
52
+
}
53
+
},
54
+
mounted() {
55
+
this.$root.$on(EVENT_SHOW, spy)
56
+
},
57
+
beforeDestroy() {
58
+
this.$root.$off(EVENT_SHOW, spy)
59
+
},
60
+
template: '<a href="#" v-b-modal.test>{{ text }}</a>'
61
+
})
62
+
const wrapper = mount(App, {
63
+
localVue: localVue
64
+
})
65
+
66
+
expect(wrapper.isVueInstance()).toBe(true)
67
+
expect(wrapper.is('a')).toBe(true)
68
+
expect(spy).not.toHaveBeenCalled()
69
+
expect(wrapper.find('a').attributes('role')).toBe('button')
70
+
expect(wrapper.find('a').attributes('tabindex')).not.toBeDefined()
71
+
expect(wrapper.find('a').text()).toBe('link')
72
+
73
+
const $link = wrapper.find('a')
74
+
$link.trigger('click')
75
+
expect(spy).toHaveBeenCalledTimes(1)
76
+
expect(spy).toBeCalledWith('test', $link.element)
77
+
expect(wrapper.find('a').attributes('role')).toBe('button')
78
+
expect(wrapper.find('a').attributes('tabindex')).not.toBeDefined()
79
+
80
+
wrapper.destroy()
81
+
})
82
+
39
83
it('works on non-buttons', async () => {
40
84
const localVue = new CreateLocalVue()
41
85
const spy = jest.fn()
@@ -55,7 +99,7 @@ describe('v-b-modal directive', () => {
55
99
beforeDestroy() {
56
100
this.$root.$off(EVENT_SHOW, spy)
57
101
},
58
-
template: '<span tabindex="0" v-b-modal.test>{{ text }}</span>'
102
+
template: '<span v-b-modal.test>{{ text }}</span>'
59
103
})
60
104
const wrapper = mount(App, {
61
105
localVue: localVue
@@ -65,6 +109,7 @@ describe('v-b-modal directive', () => {
65
109
expect(wrapper.is('span')).toBe(true)
66
110
expect(spy).not.toHaveBeenCalled()
67
111
expect(wrapper.find('span').attributes('role')).toBe('button')
112
+
expect(wrapper.find('span').attributes('tabindex')).toBe('0')
68
113
expect(wrapper.find('span').text()).toBe('span')
69
114
70
115
const $span = wrapper.find('span')
@@ -102,7 +147,7 @@ describe('v-b-modal directive', () => {
102
147
beforeDestroy() {
103
148
this.$root.$off(EVENT_SHOW, spy)
104
149
},
105
-
template: '<span tabindex="0" v-b-modal.test>{{ text }}</span>'
150
+
template: '<span v-b-modal.test>{{ text }}</span>'
106
151
})
107
152
const wrapper = mount(App, {
108
153
localVue: localVue
@@ -112,6 +157,7 @@ describe('v-b-modal directive', () => {
112
157
expect(wrapper.is('span')).toBe(true)
113
158
expect(spy).not.toHaveBeenCalled()
114
159
expect(wrapper.find('span').attributes('role')).toBe('button')
160
+
expect(wrapper.find('span').attributes('tabindex')).toBe('0')
115
161
expect(wrapper.find('span').text()).toBe('span')
116
162
117
163
const $span = wrapper.find('span')
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4