@gitlab/ui 112.1.0 → 112.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/components/charts/line/line.js +11 -7
- package/dist/components/charts/stacked_column/stacked_column.js +9 -6
- package/dist/index.js +0 -1
- package/package.json +1 -1
- package/src/components/charts/line/line.vue +9 -6
- package/src/components/charts/stacked_column/stacked_column.vue +7 -4
- package/src/index.js +0 -1
- package/src/vendor/bootstrap-vue/src/components/collapse/package.json +0 -3
- package/dist/directives/collapse_toggle.js +0 -1
- package/dist/vendor/bootstrap-vue/src/directives/toggle/index.js +0 -1
- package/dist/vendor/bootstrap-vue/src/directives/toggle/toggle.js +0 -253
- package/src/directives/collapse_toggle.js +0 -1
- package/src/vendor/bootstrap-vue/src/directives/toggle/README.md +0 -145
- package/src/vendor/bootstrap-vue/src/directives/toggle/index.js +0 -3
- package/src/vendor/bootstrap-vue/src/directives/toggle/package.json +0 -26
- package/src/vendor/bootstrap-vue/src/directives/toggle/toggle.js +0 -274
- package/src/vendor/bootstrap-vue/src/directives/toggle/toggle.spec.js +0 -452
|
@@ -1,452 +0,0 @@
|
|
|
1
|
-
import { mount } from '@vue/test-utils'
|
|
2
|
-
import { waitNT, waitRAF } from '../../../tests/utils'
|
|
3
|
-
import { VBToggle } from './toggle'
|
|
4
|
-
|
|
5
|
-
// Emitted control event for collapse (emitted to collapse)
|
|
6
|
-
const EVENT_TOGGLE = 'bv::toggle::collapse'
|
|
7
|
-
|
|
8
|
-
// Listen to event for toggle state update (emitted by collapse)
|
|
9
|
-
const EVENT_STATE = 'bv::collapse::state'
|
|
10
|
-
|
|
11
|
-
// Listen to event for toggle sync state update (emitted by collapse)
|
|
12
|
-
const EVENT_SYNC_STATE = 'bv::collapse::sync-state'
|
|
13
|
-
|
|
14
|
-
describe('v-b-toggle directive', () => {
|
|
15
|
-
it('works on buttons', async () => {
|
|
16
|
-
const spy = jest.fn()
|
|
17
|
-
const App = {
|
|
18
|
-
directives: {
|
|
19
|
-
bToggle: VBToggle
|
|
20
|
-
},
|
|
21
|
-
created() {
|
|
22
|
-
this.$root.$on(EVENT_TOGGLE, spy)
|
|
23
|
-
},
|
|
24
|
-
beforeDestroy() {
|
|
25
|
-
this.$root.$off(EVENT_TOGGLE, spy)
|
|
26
|
-
},
|
|
27
|
-
template: '<button v-b-toggle.test>button</button>'
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const wrapper = mount(App)
|
|
31
|
-
|
|
32
|
-
await waitRAF()
|
|
33
|
-
await waitNT(wrapper.vm)
|
|
34
|
-
|
|
35
|
-
expect(wrapper.vm).toBeDefined()
|
|
36
|
-
expect(wrapper.element.tagName).toBe('BUTTON')
|
|
37
|
-
expect(spy).not.toHaveBeenCalled()
|
|
38
|
-
|
|
39
|
-
const $button = wrapper.find('button')
|
|
40
|
-
expect($button.attributes('aria-controls')).toBe('test')
|
|
41
|
-
expect($button.attributes('aria-expanded')).toBe('false')
|
|
42
|
-
expect($button.attributes('tabindex')).toBeUndefined()
|
|
43
|
-
expect($button.classes()).toContain('collapsed')
|
|
44
|
-
expect($button.classes()).not.toContain('not-collapsed')
|
|
45
|
-
|
|
46
|
-
await $button.trigger('click')
|
|
47
|
-
expect(spy).toHaveBeenCalledTimes(1)
|
|
48
|
-
expect(spy).toBeCalledWith('test')
|
|
49
|
-
|
|
50
|
-
// Since there is no target collapse to respond with the
|
|
51
|
-
// current state, the classes and attrs remain the same
|
|
52
|
-
expect($button.attributes('aria-controls')).toBe('test')
|
|
53
|
-
expect($button.attributes('aria-expanded')).toBe('false')
|
|
54
|
-
expect($button.attributes('tabindex')).toBeUndefined()
|
|
55
|
-
expect($button.classes()).toContain('collapsed')
|
|
56
|
-
expect($button.classes()).not.toContain('not-collapsed')
|
|
57
|
-
|
|
58
|
-
wrapper.destroy()
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
it('works on passing ID as directive value', async () => {
|
|
62
|
-
const spy = jest.fn()
|
|
63
|
-
const App = {
|
|
64
|
-
directives: {
|
|
65
|
-
bToggle: VBToggle
|
|
66
|
-
},
|
|
67
|
-
mounted() {
|
|
68
|
-
this.$root.$on(EVENT_TOGGLE, spy)
|
|
69
|
-
},
|
|
70
|
-
beforeDestroy() {
|
|
71
|
-
this.$root.$off(EVENT_TOGGLE, spy)
|
|
72
|
-
},
|
|
73
|
-
template: `<button v-b-toggle="'test'">button</button>`
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const wrapper = mount(App)
|
|
77
|
-
|
|
78
|
-
await waitRAF()
|
|
79
|
-
await waitNT(wrapper.vm)
|
|
80
|
-
|
|
81
|
-
expect(wrapper.vm).toBeDefined()
|
|
82
|
-
expect(wrapper.element.tagName).toBe('BUTTON')
|
|
83
|
-
expect(spy).not.toHaveBeenCalled()
|
|
84
|
-
|
|
85
|
-
const $button = wrapper.find('button')
|
|
86
|
-
expect($button.attributes('aria-controls')).toBe('test')
|
|
87
|
-
expect($button.attributes('aria-expanded')).toBe('false')
|
|
88
|
-
expect($button.classes()).toContain('collapsed')
|
|
89
|
-
expect($button.classes()).not.toContain('not-collapsed')
|
|
90
|
-
|
|
91
|
-
await $button.trigger('click')
|
|
92
|
-
expect(spy).toHaveBeenCalledTimes(1)
|
|
93
|
-
expect(spy).toBeCalledWith('test')
|
|
94
|
-
|
|
95
|
-
// Since there is no target collapse to respond with the
|
|
96
|
-
// current state, the classes and attrs remain the same
|
|
97
|
-
expect($button.attributes('aria-controls')).toBe('test')
|
|
98
|
-
expect($button.attributes('aria-expanded')).toBe('false')
|
|
99
|
-
expect($button.classes()).toContain('collapsed')
|
|
100
|
-
expect($button.classes()).not.toContain('not-collapsed')
|
|
101
|
-
|
|
102
|
-
wrapper.destroy()
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
it('works on passing ID as directive argument', async () => {
|
|
106
|
-
const spy = jest.fn()
|
|
107
|
-
const App = {
|
|
108
|
-
directives: {
|
|
109
|
-
bToggle: VBToggle
|
|
110
|
-
},
|
|
111
|
-
mounted() {
|
|
112
|
-
this.$root.$on(EVENT_TOGGLE, spy)
|
|
113
|
-
},
|
|
114
|
-
beforeDestroy() {
|
|
115
|
-
this.$root.$off(EVENT_TOGGLE, spy)
|
|
116
|
-
},
|
|
117
|
-
template: `<button v-b-toggle:test>button</button>`
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const wrapper = mount(App)
|
|
121
|
-
|
|
122
|
-
await waitRAF()
|
|
123
|
-
await waitNT(wrapper.vm)
|
|
124
|
-
|
|
125
|
-
expect(wrapper.vm).toBeDefined()
|
|
126
|
-
expect(wrapper.element.tagName).toBe('BUTTON')
|
|
127
|
-
expect(spy).not.toHaveBeenCalled()
|
|
128
|
-
|
|
129
|
-
const $button = wrapper.find('button')
|
|
130
|
-
expect($button.attributes('aria-controls')).toBe('test')
|
|
131
|
-
expect($button.attributes('aria-expanded')).toBe('false')
|
|
132
|
-
expect($button.classes()).toContain('collapsed')
|
|
133
|
-
expect($button.classes()).not.toContain('not-collapsed')
|
|
134
|
-
|
|
135
|
-
await $button.trigger('click')
|
|
136
|
-
expect(spy).toHaveBeenCalledTimes(1)
|
|
137
|
-
expect(spy).toBeCalledWith('test')
|
|
138
|
-
|
|
139
|
-
// Since there is no target collapse to respond with the
|
|
140
|
-
// current state, the classes and attrs remain the same
|
|
141
|
-
expect($button.attributes('aria-controls')).toBe('test')
|
|
142
|
-
expect($button.attributes('aria-expanded')).toBe('false')
|
|
143
|
-
expect($button.classes()).toContain('collapsed')
|
|
144
|
-
expect($button.classes()).not.toContain('not-collapsed')
|
|
145
|
-
|
|
146
|
-
wrapper.destroy()
|
|
147
|
-
})
|
|
148
|
-
|
|
149
|
-
it('works on passing ID as href value on links', async () => {
|
|
150
|
-
const spy = jest.fn()
|
|
151
|
-
const App = {
|
|
152
|
-
directives: {
|
|
153
|
-
bToggle: VBToggle
|
|
154
|
-
},
|
|
155
|
-
created() {
|
|
156
|
-
this.$root.$on(EVENT_TOGGLE, spy)
|
|
157
|
-
},
|
|
158
|
-
beforeDestroy() {
|
|
159
|
-
this.$root.$off(EVENT_TOGGLE, spy)
|
|
160
|
-
},
|
|
161
|
-
template: '<a href="#test" v-b-toggle>link</a>'
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
const wrapper = mount(App)
|
|
165
|
-
|
|
166
|
-
await waitRAF()
|
|
167
|
-
await waitNT(wrapper.vm)
|
|
168
|
-
|
|
169
|
-
expect(wrapper.vm).toBeDefined()
|
|
170
|
-
expect(wrapper.element.tagName).toBe('A')
|
|
171
|
-
expect(spy).not.toHaveBeenCalled()
|
|
172
|
-
|
|
173
|
-
const $link = wrapper.find('a')
|
|
174
|
-
expect($link.attributes('aria-controls')).toBe('test')
|
|
175
|
-
expect($link.attributes('aria-expanded')).toBe('false')
|
|
176
|
-
expect($link.attributes('tabindex')).toBeUndefined()
|
|
177
|
-
expect($link.classes()).toContain('collapsed')
|
|
178
|
-
expect($link.classes()).not.toContain('not-collapsed')
|
|
179
|
-
|
|
180
|
-
await $link.trigger('click')
|
|
181
|
-
expect(spy).toHaveBeenCalledTimes(1)
|
|
182
|
-
expect(spy).toBeCalledWith('test')
|
|
183
|
-
|
|
184
|
-
// Since there is no target collapse to respond with the
|
|
185
|
-
// current state, the classes and attrs remain the same
|
|
186
|
-
expect($link.attributes('aria-controls')).toBe('test')
|
|
187
|
-
expect($link.attributes('aria-expanded')).toBe('false')
|
|
188
|
-
expect($link.attributes('tabindex')).toBeUndefined()
|
|
189
|
-
expect($link.classes()).toContain('collapsed')
|
|
190
|
-
expect($link.classes()).not.toContain('not-collapsed')
|
|
191
|
-
|
|
192
|
-
wrapper.destroy()
|
|
193
|
-
})
|
|
194
|
-
|
|
195
|
-
it('works with multiple targets, and updates when targets change', async () => {
|
|
196
|
-
const spy = jest.fn()
|
|
197
|
-
const App = {
|
|
198
|
-
directives: {
|
|
199
|
-
bToggle: VBToggle
|
|
200
|
-
},
|
|
201
|
-
props: {
|
|
202
|
-
target: {
|
|
203
|
-
type: [String, Array],
|
|
204
|
-
default: null
|
|
205
|
-
}
|
|
206
|
-
},
|
|
207
|
-
mounted() {
|
|
208
|
-
this.$root.$on(EVENT_TOGGLE, spy)
|
|
209
|
-
},
|
|
210
|
-
beforeDestroy() {
|
|
211
|
-
this.$root.$off(EVENT_TOGGLE, spy)
|
|
212
|
-
},
|
|
213
|
-
template: `<button v-b-toggle="target">button</button>`
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
const wrapper = mount(App, {
|
|
217
|
-
propsData: {
|
|
218
|
-
target: 'test1'
|
|
219
|
-
}
|
|
220
|
-
})
|
|
221
|
-
|
|
222
|
-
await waitRAF()
|
|
223
|
-
await waitNT(wrapper.vm)
|
|
224
|
-
|
|
225
|
-
expect(wrapper.vm).toBeDefined()
|
|
226
|
-
expect(wrapper.element.tagName).toBe('BUTTON')
|
|
227
|
-
expect(spy).not.toHaveBeenCalled()
|
|
228
|
-
|
|
229
|
-
const $button = wrapper.find('button')
|
|
230
|
-
expect($button.attributes('aria-controls')).toBe('test1')
|
|
231
|
-
expect($button.attributes('aria-expanded')).toBe('false')
|
|
232
|
-
expect($button.classes()).toContain('collapsed')
|
|
233
|
-
expect($button.classes()).not.toContain('not-collapsed')
|
|
234
|
-
|
|
235
|
-
await wrapper.setProps({ target: ['test1', 'test2'] })
|
|
236
|
-
expect($button.attributes('aria-controls')).toBe('test1 test2')
|
|
237
|
-
expect($button.attributes('aria-expanded')).toBe('false')
|
|
238
|
-
expect($button.classes()).toContain('collapsed')
|
|
239
|
-
expect($button.classes()).not.toContain('not-collapsed')
|
|
240
|
-
expect(spy).not.toHaveBeenCalled()
|
|
241
|
-
|
|
242
|
-
await $button.trigger('click')
|
|
243
|
-
expect(spy).toHaveBeenCalledTimes(2)
|
|
244
|
-
expect(spy).toHaveBeenNthCalledWith(1, 'test1')
|
|
245
|
-
expect(spy).toHaveBeenNthCalledWith(2, 'test2')
|
|
246
|
-
|
|
247
|
-
// Since there is no target collapse to respond with the
|
|
248
|
-
// current state, the classes and attrs remain the same
|
|
249
|
-
expect($button.attributes('aria-controls')).toBe('test1 test2')
|
|
250
|
-
expect($button.attributes('aria-expanded')).toBe('false')
|
|
251
|
-
expect($button.classes()).toContain('collapsed')
|
|
252
|
-
expect($button.classes()).not.toContain('not-collapsed')
|
|
253
|
-
|
|
254
|
-
await wrapper.setProps({ target: ['test2'] })
|
|
255
|
-
expect($button.attributes('aria-controls')).toBe('test2')
|
|
256
|
-
expect($button.attributes('aria-expanded')).toBe('false')
|
|
257
|
-
expect($button.classes()).toContain('collapsed')
|
|
258
|
-
expect($button.classes()).not.toContain('not-collapsed')
|
|
259
|
-
expect(spy).toHaveBeenCalledTimes(2)
|
|
260
|
-
|
|
261
|
-
await $button.trigger('click')
|
|
262
|
-
expect(spy).toHaveBeenCalledTimes(3)
|
|
263
|
-
expect(spy).toHaveBeenNthCalledWith(3, 'test2')
|
|
264
|
-
|
|
265
|
-
// Since there is no target collapse to respond with the
|
|
266
|
-
// current state, the classes and attrs remain the same
|
|
267
|
-
expect($button.attributes('aria-controls')).toBe('test2')
|
|
268
|
-
expect($button.attributes('aria-expanded')).toBe('false')
|
|
269
|
-
expect($button.classes()).toContain('collapsed')
|
|
270
|
-
expect($button.classes()).not.toContain('not-collapsed')
|
|
271
|
-
|
|
272
|
-
wrapper.destroy()
|
|
273
|
-
})
|
|
274
|
-
|
|
275
|
-
it('works on non-buttons', async () => {
|
|
276
|
-
const spy = jest.fn()
|
|
277
|
-
const App = {
|
|
278
|
-
directives: {
|
|
279
|
-
bToggle: VBToggle
|
|
280
|
-
},
|
|
281
|
-
data() {
|
|
282
|
-
return {
|
|
283
|
-
text: 'span'
|
|
284
|
-
}
|
|
285
|
-
},
|
|
286
|
-
mounted() {
|
|
287
|
-
this.$root.$on(EVENT_TOGGLE, spy)
|
|
288
|
-
},
|
|
289
|
-
beforeDestroy() {
|
|
290
|
-
this.$root.$off(EVENT_TOGGLE, spy)
|
|
291
|
-
},
|
|
292
|
-
template: '<span v-b-toggle.test>{{ text }}</span>'
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
const wrapper = mount(App)
|
|
296
|
-
|
|
297
|
-
await waitRAF()
|
|
298
|
-
await waitNT(wrapper.vm)
|
|
299
|
-
|
|
300
|
-
expect(wrapper.vm).toBeDefined()
|
|
301
|
-
expect(wrapper.element.tagName).toBe('SPAN')
|
|
302
|
-
expect(spy).not.toHaveBeenCalled()
|
|
303
|
-
|
|
304
|
-
const $span = wrapper.find('span')
|
|
305
|
-
expect($span.attributes('role')).toBe('button')
|
|
306
|
-
expect($span.attributes('tabindex')).toBe('0')
|
|
307
|
-
expect($span.attributes('aria-controls')).toBe('test')
|
|
308
|
-
expect($span.attributes('aria-expanded')).toBe('false')
|
|
309
|
-
expect($span.classes()).toContain('collapsed')
|
|
310
|
-
expect($span.classes()).not.toContain('not-collapsed')
|
|
311
|
-
expect($span.text()).toBe('span')
|
|
312
|
-
|
|
313
|
-
await $span.trigger('click')
|
|
314
|
-
expect(spy).toHaveBeenCalledTimes(1)
|
|
315
|
-
expect(spy).toBeCalledWith('test')
|
|
316
|
-
expect($span.attributes('role')).toBe('button')
|
|
317
|
-
expect($span.attributes('tabindex')).toBe('0')
|
|
318
|
-
|
|
319
|
-
// Since there is no target collapse to respond with the
|
|
320
|
-
// current state, the classes and attrs remain the same
|
|
321
|
-
expect($span.attributes('aria-controls')).toBe('test')
|
|
322
|
-
expect($span.attributes('aria-expanded')).toBe('false')
|
|
323
|
-
expect($span.classes()).toContain('collapsed')
|
|
324
|
-
expect($span.classes()).not.toContain('not-collapsed')
|
|
325
|
-
|
|
326
|
-
// Reacts to SPACE keypress
|
|
327
|
-
await $span.trigger('keydown.space')
|
|
328
|
-
expect(spy).toHaveBeenCalledTimes(2)
|
|
329
|
-
expect(spy).toBeCalledWith('test')
|
|
330
|
-
expect($span.attributes('role')).toBe('button')
|
|
331
|
-
expect($span.attributes('tabindex')).toBe('0')
|
|
332
|
-
|
|
333
|
-
// Since there is no target collapse to respond with the
|
|
334
|
-
// current state, the classes and attrs remain the same
|
|
335
|
-
expect($span.attributes('aria-controls')).toBe('test')
|
|
336
|
-
expect($span.attributes('aria-expanded')).toBe('false')
|
|
337
|
-
expect($span.classes()).toContain('collapsed')
|
|
338
|
-
expect($span.classes()).not.toContain('not-collapsed')
|
|
339
|
-
|
|
340
|
-
// Reacts to ENTER keypress
|
|
341
|
-
await $span.trigger('keydown.enter')
|
|
342
|
-
expect(spy).toHaveBeenCalledTimes(3)
|
|
343
|
-
expect(spy).toBeCalledWith('test')
|
|
344
|
-
expect($span.attributes('role')).toBe('button')
|
|
345
|
-
expect($span.attributes('tabindex')).toBe('0')
|
|
346
|
-
|
|
347
|
-
// Since there is no target collapse to respond with the
|
|
348
|
-
// current state, the classes and attrs remain the same
|
|
349
|
-
expect($span.attributes('aria-controls')).toBe('test')
|
|
350
|
-
expect($span.attributes('aria-expanded')).toBe('false')
|
|
351
|
-
expect($span.classes()).toContain('collapsed')
|
|
352
|
-
expect($span.classes()).not.toContain('not-collapsed')
|
|
353
|
-
|
|
354
|
-
// Test updating component, should maintain role attribute
|
|
355
|
-
await wrapper.setData({ text: 'foobar' })
|
|
356
|
-
expect($span.text()).toBe('foobar')
|
|
357
|
-
expect($span.attributes('role')).toBe('button')
|
|
358
|
-
expect($span.attributes('tabindex')).toBe('0')
|
|
359
|
-
|
|
360
|
-
// Since there is no target collapse to respond with the
|
|
361
|
-
// current state, the classes and attrs remain the same
|
|
362
|
-
expect($span.attributes('aria-controls')).toBe('test')
|
|
363
|
-
expect($span.attributes('aria-expanded')).toBe('false')
|
|
364
|
-
expect($span.classes()).toContain('collapsed')
|
|
365
|
-
expect($span.classes()).not.toContain('not-collapsed')
|
|
366
|
-
|
|
367
|
-
wrapper.destroy()
|
|
368
|
-
})
|
|
369
|
-
|
|
370
|
-
it('responds to state update events', async () => {
|
|
371
|
-
const App = {
|
|
372
|
-
directives: {
|
|
373
|
-
bToggle: VBToggle
|
|
374
|
-
},
|
|
375
|
-
template: '<button v-b-toggle.test>button</button>'
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
const wrapper = mount(App)
|
|
379
|
-
|
|
380
|
-
expect(wrapper.vm).toBeDefined()
|
|
381
|
-
expect(wrapper.element.tagName).toBe('BUTTON')
|
|
382
|
-
|
|
383
|
-
const $root = wrapper.vm.$root
|
|
384
|
-
|
|
385
|
-
const $button = wrapper.find('button')
|
|
386
|
-
expect($button.attributes('aria-controls')).toBe('test')
|
|
387
|
-
expect($button.attributes('aria-expanded')).toBe('false')
|
|
388
|
-
expect($button.classes()).toContain('collapsed')
|
|
389
|
-
expect($button.classes()).not.toContain('not-collapsed')
|
|
390
|
-
|
|
391
|
-
$root.$emit(EVENT_STATE, 'test', true)
|
|
392
|
-
await waitNT(wrapper.vm)
|
|
393
|
-
expect($button.attributes('aria-controls')).toBe('test')
|
|
394
|
-
expect($button.attributes('aria-expanded')).toBe('true')
|
|
395
|
-
expect($button.classes()).not.toContain('collapsed')
|
|
396
|
-
expect($button.classes()).toContain('not-collapsed')
|
|
397
|
-
|
|
398
|
-
$root.$emit(EVENT_STATE, 'test', false)
|
|
399
|
-
await waitNT(wrapper.vm)
|
|
400
|
-
expect($button.attributes('aria-controls')).toBe('test')
|
|
401
|
-
expect($button.attributes('aria-expanded')).toBe('false')
|
|
402
|
-
expect($button.classes()).toContain('collapsed')
|
|
403
|
-
expect($button.classes()).not.toContain('not-collapsed')
|
|
404
|
-
|
|
405
|
-
$root.$emit(EVENT_STATE, 'test', true)
|
|
406
|
-
await waitNT(wrapper.vm)
|
|
407
|
-
expect($button.attributes('aria-controls')).toBe('test')
|
|
408
|
-
expect($button.attributes('aria-expanded')).toBe('true')
|
|
409
|
-
expect($button.classes()).not.toContain('collapsed')
|
|
410
|
-
expect($button.classes()).toContain('not-collapsed')
|
|
411
|
-
|
|
412
|
-
wrapper.destroy()
|
|
413
|
-
})
|
|
414
|
-
|
|
415
|
-
it('responds to private sync state update events', async () => {
|
|
416
|
-
const App = {
|
|
417
|
-
directives: {
|
|
418
|
-
bToggle: VBToggle
|
|
419
|
-
},
|
|
420
|
-
template: '<button v-b-toggle.test>button</button>'
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
const wrapper = mount(App)
|
|
424
|
-
|
|
425
|
-
expect(wrapper.vm).toBeDefined()
|
|
426
|
-
expect(wrapper.element.tagName).toBe('BUTTON')
|
|
427
|
-
|
|
428
|
-
const $root = wrapper.vm.$root
|
|
429
|
-
|
|
430
|
-
const $button = wrapper.find('button')
|
|
431
|
-
expect($button.attributes('aria-controls')).toBe('test')
|
|
432
|
-
expect($button.attributes('aria-expanded')).toBe('false')
|
|
433
|
-
expect($button.classes()).toContain('collapsed')
|
|
434
|
-
expect($button.classes()).not.toContain('not-collapsed')
|
|
435
|
-
|
|
436
|
-
$root.$emit(EVENT_SYNC_STATE, 'test', true)
|
|
437
|
-
await waitNT(wrapper.vm)
|
|
438
|
-
expect($button.attributes('aria-controls')).toBe('test')
|
|
439
|
-
expect($button.attributes('aria-expanded')).toBe('true')
|
|
440
|
-
expect($button.classes()).not.toContain('collapsed')
|
|
441
|
-
expect($button.classes()).toContain('not-collapsed')
|
|
442
|
-
|
|
443
|
-
$root.$emit(EVENT_SYNC_STATE, 'test', false)
|
|
444
|
-
await waitNT(wrapper.vm)
|
|
445
|
-
expect($button.attributes('aria-controls')).toBe('test')
|
|
446
|
-
expect($button.attributes('aria-expanded')).toBe('false')
|
|
447
|
-
expect($button.classes()).toContain('collapsed')
|
|
448
|
-
expect($button.classes()).not.toContain('not-collapsed')
|
|
449
|
-
|
|
450
|
-
wrapper.destroy()
|
|
451
|
-
})
|
|
452
|
-
})
|