@gitlab/ui 114.1.0 → 114.1.2
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/dist/components/base/breadcrumb/breadcrumb.js +4 -16
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/package.json +7 -26
- package/src/components/base/breadcrumb/breadcrumb.scss +18 -2
- package/src/components/base/breadcrumb/breadcrumb.vue +4 -17
- package/CHANGELOG.md +0 -13139
- package/src/vendor/bootstrap/LICENSE +0 -11
- package/src/vendor/bootstrap-vue/LICENSE +0 -11
- package/src/vendor/bootstrap-vue/package.json +0 -144
- package/src/vendor/bootstrap-vue/src/components/button/MODIFICATIONS.md +0 -16
- package/src/vendor/bootstrap-vue/src/components/button/README.md +0 -240
- package/src/vendor/bootstrap-vue/src/components/button/button-close.spec.js +0 -210
- package/src/vendor/bootstrap-vue/src/components/button/button.spec.js +0 -349
- package/src/vendor/bootstrap-vue/src/components/button/package.json +0 -105
- package/src/vendor/bootstrap-vue/src/components/dropdown/README.md +0 -730
- package/src/vendor/bootstrap-vue/src/components/dropdown/dropdown-divider.spec.js +0 -58
- package/src/vendor/bootstrap-vue/src/components/dropdown/dropdown-form.spec.js +0 -110
- package/src/vendor/bootstrap-vue/src/components/dropdown/dropdown-group.spec.js +0 -94
- package/src/vendor/bootstrap-vue/src/components/dropdown/dropdown-header.spec.js +0 -73
- package/src/vendor/bootstrap-vue/src/components/dropdown/dropdown-item-button.spec.js +0 -117
- package/src/vendor/bootstrap-vue/src/components/dropdown/dropdown-item.spec.js +0 -147
- package/src/vendor/bootstrap-vue/src/components/dropdown/dropdown-text.spec.js +0 -59
- package/src/vendor/bootstrap-vue/src/components/dropdown/dropdown.spec.js +0 -1121
- package/src/vendor/bootstrap-vue/src/components/dropdown/package.json +0 -368
- package/src/vendor/bootstrap-vue/src/components/form/README.md +0 -365
- package/src/vendor/bootstrap-vue/src/components/form/form-invalid-feedback.spec.js +0 -170
- package/src/vendor/bootstrap-vue/src/components/form/form-text.spec.js +0 -93
- package/src/vendor/bootstrap-vue/src/components/form/form-valid-feedback.spec.js +0 -157
- package/src/vendor/bootstrap-vue/src/components/form/form.spec.js +0 -97
- package/src/vendor/bootstrap-vue/src/components/form/package.json +0 -112
- package/src/vendor/bootstrap-vue/src/components/form-checkbox/README.md +0 -691
- package/src/vendor/bootstrap-vue/src/components/form-checkbox/form-checkbox-group.spec.js +0 -525
- package/src/vendor/bootstrap-vue/src/components/form-checkbox/form-checkbox.spec.js +0 -922
- package/src/vendor/bootstrap-vue/src/components/form-checkbox/package.json +0 -172
- package/src/vendor/bootstrap-vue/src/components/form-group/README.md +0 -339
- package/src/vendor/bootstrap-vue/src/components/form-group/form-group.spec.js +0 -477
- package/src/vendor/bootstrap-vue/src/components/form-group/package.json +0 -183
- package/src/vendor/bootstrap-vue/src/components/form-radio/README.md +0 -437
- package/src/vendor/bootstrap-vue/src/components/form-radio/form-radio-group.spec.js +0 -357
- package/src/vendor/bootstrap-vue/src/components/form-radio/form-radio.spec.js +0 -587
- package/src/vendor/bootstrap-vue/src/components/form-radio/package.json +0 -162
- package/src/vendor/bootstrap-vue/src/components/form-select/README.md +0 -504
- package/src/vendor/bootstrap-vue/src/components/form-select/form-select-option-group.spec.js +0 -138
- package/src/vendor/bootstrap-vue/src/components/form-select/form-select-option.spec.js +0 -75
- package/src/vendor/bootstrap-vue/src/components/form-select/form-select.spec.js +0 -723
- package/src/vendor/bootstrap-vue/src/components/form-select/package.json +0 -132
- package/src/vendor/bootstrap-vue/src/components/form-textarea/README.md +0 -453
- package/src/vendor/bootstrap-vue/src/components/form-textarea/form-textarea.spec.js +0 -1000
- package/src/vendor/bootstrap-vue/src/components/form-textarea/package.json +0 -122
- package/src/vendor/bootstrap-vue/src/components/layout/README.md +0 -791
- package/src/vendor/bootstrap-vue/src/components/layout/col.spec.js +0 -192
- package/src/vendor/bootstrap-vue/src/components/layout/form-row.spec.js +0 -45
- package/src/vendor/bootstrap-vue/src/components/layout/package.json +0 -99
- package/src/vendor/bootstrap-vue/src/components/link/README.md +0 -76
- package/src/vendor/bootstrap-vue/src/components/link/link.spec.js +0 -434
- package/src/vendor/bootstrap-vue/src/components/link/package.json +0 -57
- package/src/vendor/bootstrap-vue/src/components/modal/MODIFICATIONS.md +0 -30
- package/src/vendor/bootstrap-vue/src/components/modal/README.md +0 -1067
- package/src/vendor/bootstrap-vue/src/components/modal/helpers/bv-modal-event.class.spec.js +0 -82
- package/src/vendor/bootstrap-vue/src/components/modal/modal.spec.js +0 -1418
- package/src/vendor/bootstrap-vue/src/components/modal/package.json +0 -544
- package/src/vendor/bootstrap-vue/src/components/nav/README.md +0 -362
- package/src/vendor/bootstrap-vue/src/components/nav/nav-item.spec.js +0 -127
- package/src/vendor/bootstrap-vue/src/components/nav/nav.spec.js +0 -177
- package/src/vendor/bootstrap-vue/src/components/nav/package.json +0 -73
- package/src/vendor/bootstrap-vue/src/components/popover/README.md +0 -919
- package/src/vendor/bootstrap-vue/src/components/popover/package.json +0 -261
- package/src/vendor/bootstrap-vue/src/components/popover/popover.spec.js +0 -198
- package/src/vendor/bootstrap-vue/src/components/table/README.md +0 -3157
- package/src/vendor/bootstrap-vue/src/components/table/helpers/default-sort-compare.spec.js +0 -112
- package/src/vendor/bootstrap-vue/src/components/table/helpers/normalize-fields.spec.js +0 -93
- package/src/vendor/bootstrap-vue/src/components/table/package.json +0 -1763
- package/src/vendor/bootstrap-vue/src/components/table/table-busy.spec.js +0 -150
- package/src/vendor/bootstrap-vue/src/components/table/table-caption.spec.js +0 -176
- package/src/vendor/bootstrap-vue/src/components/table/table-colgroup.spec.js +0 -81
- package/src/vendor/bootstrap-vue/src/components/table/table-filtering.spec.js +0 -409
- package/src/vendor/bootstrap-vue/src/components/table/table-item-formatter.spec.js +0 -56
- package/src/vendor/bootstrap-vue/src/components/table/table-lite.spec.js +0 -682
- package/src/vendor/bootstrap-vue/src/components/table/table-pagination.spec.js +0 -133
- package/src/vendor/bootstrap-vue/src/components/table/table-primarykey.spec.js +0 -83
- package/src/vendor/bootstrap-vue/src/components/table/table-provider.spec.js +0 -411
- package/src/vendor/bootstrap-vue/src/components/table/table-row-details.spec.js +0 -459
- package/src/vendor/bootstrap-vue/src/components/table/table-selectable.spec.js +0 -1182
- package/src/vendor/bootstrap-vue/src/components/table/table-simple.spec.js +0 -206
- package/src/vendor/bootstrap-vue/src/components/table/table-sorting.spec.js +0 -858
- package/src/vendor/bootstrap-vue/src/components/table/table-sticky-column.spec.js +0 -377
- package/src/vendor/bootstrap-vue/src/components/table/table-tbody-bottom-row.spec.js +0 -94
- package/src/vendor/bootstrap-vue/src/components/table/table-tbody-row-events.spec.js +0 -529
- package/src/vendor/bootstrap-vue/src/components/table/table-tbody-top-row.spec.js +0 -88
- package/src/vendor/bootstrap-vue/src/components/table/table-tbody-transition.spec.js +0 -83
- package/src/vendor/bootstrap-vue/src/components/table/table-tfoot-custom.spec.js +0 -91
- package/src/vendor/bootstrap-vue/src/components/table/table-tfoot-events.spec.js +0 -137
- package/src/vendor/bootstrap-vue/src/components/table/table-thead-events.spec.js +0 -155
- package/src/vendor/bootstrap-vue/src/components/table/table-thead-top.spec.js +0 -96
- package/src/vendor/bootstrap-vue/src/components/table/table.spec.js +0 -692
- package/src/vendor/bootstrap-vue/src/components/tabs/README.md +0 -433
- package/src/vendor/bootstrap-vue/src/components/tabs/package.json +0 -205
- package/src/vendor/bootstrap-vue/src/components/tabs/tab.spec.js +0 -330
- package/src/vendor/bootstrap-vue/src/components/tabs/tabs.spec.js +0 -778
- package/src/vendor/bootstrap-vue/src/components/toast/README.md +0 -655
- package/src/vendor/bootstrap-vue/src/components/toast/helpers/bv-toast.spec.js +0 -117
- package/src/vendor/bootstrap-vue/src/components/toast/package.json +0 -184
- package/src/vendor/bootstrap-vue/src/components/toast/toast.spec.js +0 -294
- package/src/vendor/bootstrap-vue/src/components/toast/toaster.spec.js +0 -77
- package/src/vendor/bootstrap-vue/src/components/tooltip/README.md +0 -559
- package/src/vendor/bootstrap-vue/src/components/tooltip/package.json +0 -258
- package/src/vendor/bootstrap-vue/src/components/tooltip/tooltip.spec.js +0 -1240
- package/src/vendor/bootstrap-vue/src/components/transition/package.json +0 -5
- package/src/vendor/bootstrap-vue/src/components/transporter/package.json +0 -5
- package/src/vendor/bootstrap-vue/src/components/transporter/transporter.spec.js +0 -85
- package/src/vendor/bootstrap-vue/src/directives/modal/modal.spec.js +0 -191
- package/src/vendor/bootstrap-vue/src/directives/tooltip/README.md +0 -521
- package/src/vendor/bootstrap-vue/src/directives/tooltip/package.json +0 -131
- package/src/vendor/bootstrap-vue/src/directives/tooltip/tooltip.spec.js +0 -190
- package/src/vendor/bootstrap-vue/src/directives/visible/README.md +0 -244
- package/src/vendor/bootstrap-vue/src/directives/visible/package.json +0 -24
- package/src/vendor/bootstrap-vue/src/mixins/attrs.spec.js +0 -194
- package/src/vendor/bootstrap-vue/src/mixins/click-out.spec.js +0 -52
- package/src/vendor/bootstrap-vue/src/mixins/focus-in.spec.js +0 -53
- package/src/vendor/bootstrap-vue/src/mixins/listen-on-document.spec.js +0 -117
- package/src/vendor/bootstrap-vue/src/mixins/listen-on-root.spec.js +0 -77
- package/src/vendor/bootstrap-vue/src/mixins/listen-on-window.spec.js +0 -115
- package/src/vendor/bootstrap-vue/src/mixins/listeners.spec.js +0 -245
- package/src/vendor/bootstrap-vue/src/utils/bv-event.class.spec.js +0 -66
- package/src/vendor/bootstrap-vue/src/utils/clone-deep.spec.js +0 -70
- package/src/vendor/bootstrap-vue/src/utils/config.spec.js +0 -169
- package/src/vendor/bootstrap-vue/src/utils/css-escape.spec.js +0 -82
- package/src/vendor/bootstrap-vue/src/utils/dom.spec.js +0 -291
- package/src/vendor/bootstrap-vue/src/utils/events.spec.js +0 -41
- package/src/vendor/bootstrap-vue/src/utils/get.spec.js +0 -109
- package/src/vendor/bootstrap-vue/src/utils/inspect.spec.js +0 -251
- package/src/vendor/bootstrap-vue/src/utils/loose-equal.spec.js +0 -203
- package/src/vendor/bootstrap-vue/src/utils/normalize-slot.spec.js +0 -63
- package/src/vendor/bootstrap-vue/src/utils/number.spec.js +0 -72
- package/src/vendor/bootstrap-vue/src/utils/object.spec.js +0 -61
- package/src/vendor/bootstrap-vue/src/utils/props.spec.js +0 -112
- package/src/vendor/bootstrap-vue/src/utils/router.spec.js +0 -248
- package/src/vendor/bootstrap-vue/src/utils/string.spec.js +0 -65
- package/src/vendor/bootstrap-vue/src/utils/stringify-object-values.spec.js +0 -47
- package/src/vendor/bootstrap-vue/src/utils/warn.spec.js +0 -54
|
@@ -1,1418 +0,0 @@
|
|
|
1
|
-
import { createWrapper, mount } from '@vue/test-utils'
|
|
2
|
-
import { isVue3 } from '../../vue'
|
|
3
|
-
import { waitNT, waitRAF, getInstanceFromVNode } from '../../../tests/utils'
|
|
4
|
-
import { BModal } from './modal'
|
|
5
|
-
import { BvModalEvent } from './helpers/bv-modal-event.class'
|
|
6
|
-
|
|
7
|
-
// The default Z-INDEX for modal backdrop
|
|
8
|
-
const DEFAULT_ZINDEX = 1040
|
|
9
|
-
|
|
10
|
-
describe('modal', () => {
|
|
11
|
-
const origGetBCR = Element.prototype.getBoundingClientRect
|
|
12
|
-
|
|
13
|
-
beforeEach(() => {
|
|
14
|
-
// Mock `getBCR()` so that the `isVisible(el)` test returns `true`
|
|
15
|
-
// Needed for z-index checks
|
|
16
|
-
Element.prototype.getBoundingClientRect = jest.fn(() => ({
|
|
17
|
-
width: 24,
|
|
18
|
-
height: 24,
|
|
19
|
-
top: 0,
|
|
20
|
-
left: 0,
|
|
21
|
-
bottom: 0,
|
|
22
|
-
right: 0
|
|
23
|
-
}))
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
afterEach(() => {
|
|
27
|
-
// Restore prototype
|
|
28
|
-
Element.prototype.getBoundingClientRect = origGetBCR
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
describe('structure', () => {
|
|
32
|
-
it('has expected default structure', async () => {
|
|
33
|
-
const wrapper = mount(BModal, {
|
|
34
|
-
attachTo: document.body,
|
|
35
|
-
propsData: {
|
|
36
|
-
static: true,
|
|
37
|
-
id: 'test'
|
|
38
|
-
}
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
expect(wrapper.vm).toBeDefined()
|
|
42
|
-
await waitNT(wrapper.vm)
|
|
43
|
-
|
|
44
|
-
// Main outer wrapper (has z-index, etc.)... The stacker <div>
|
|
45
|
-
expect(wrapper.element.tagName).toBe('DIV')
|
|
46
|
-
expect(wrapper.classes().length).toBe(0)
|
|
47
|
-
expect(wrapper.element.style.position).toEqual('absolute')
|
|
48
|
-
expect(wrapper.element.style.zIndex).toEqual(`${DEFAULT_ZINDEX}`)
|
|
49
|
-
|
|
50
|
-
// Should not have a backdrop
|
|
51
|
-
expect(wrapper.find('div.modal-backdrop').exists()).toBe(false)
|
|
52
|
-
|
|
53
|
-
// Main modal wrapper
|
|
54
|
-
const $modal = wrapper.find('div.modal')
|
|
55
|
-
expect($modal.exists()).toBe(true)
|
|
56
|
-
expect($modal.attributes('id')).toBeDefined()
|
|
57
|
-
expect($modal.attributes('id')).toEqual('test')
|
|
58
|
-
expect($modal.attributes('role')).toBeDefined()
|
|
59
|
-
expect($modal.attributes('role')).toEqual('dialog')
|
|
60
|
-
expect($modal.attributes('aria-hidden')).toBeDefined()
|
|
61
|
-
expect($modal.attributes('aria-hidden')).toEqual('true')
|
|
62
|
-
expect($modal.classes()).toContain('modal')
|
|
63
|
-
expect($modal.element.style.display).toEqual('none')
|
|
64
|
-
|
|
65
|
-
// Modal dialog wrapper
|
|
66
|
-
const $dialog = $modal.find('div.modal-dialog')
|
|
67
|
-
expect($dialog.exists()).toBe(true)
|
|
68
|
-
|
|
69
|
-
// Modal content wrapper
|
|
70
|
-
const $content = $dialog.find('div.modal-content')
|
|
71
|
-
expect($content.exists()).toBe(true)
|
|
72
|
-
expect($content.attributes('tabindex')).toBeDefined()
|
|
73
|
-
expect($content.attributes('tabindex')).toEqual('-1')
|
|
74
|
-
|
|
75
|
-
wrapper.destroy()
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
it('has expected default structure when static and lazy', async () => {
|
|
79
|
-
const wrapper = mount(BModal, {
|
|
80
|
-
attachTo: document.body,
|
|
81
|
-
propsData: {
|
|
82
|
-
static: true,
|
|
83
|
-
lazy: true
|
|
84
|
-
}
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
expect(wrapper.vm).toBeDefined()
|
|
88
|
-
|
|
89
|
-
await waitNT(wrapper.vm)
|
|
90
|
-
expect(wrapper.element.nodeType).toEqual(Node.COMMENT_NODE)
|
|
91
|
-
|
|
92
|
-
wrapper.destroy()
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
it('has expected default structure when not static', async () => {
|
|
96
|
-
const wrapper = mount(BModal, {
|
|
97
|
-
attachTo: document.body,
|
|
98
|
-
propsData: {
|
|
99
|
-
static: false
|
|
100
|
-
}
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
expect(wrapper.vm).toBeDefined()
|
|
104
|
-
|
|
105
|
-
await waitNT(wrapper.vm)
|
|
106
|
-
expect(wrapper.element.nodeType).toEqual(Node.COMMENT_NODE)
|
|
107
|
-
|
|
108
|
-
wrapper.destroy()
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
it('has expected structure when initially open', async () => {
|
|
112
|
-
const wrapper = mount(BModal, {
|
|
113
|
-
attachTo: document.body,
|
|
114
|
-
propsData: {
|
|
115
|
-
static: true,
|
|
116
|
-
id: 'test',
|
|
117
|
-
visible: true
|
|
118
|
-
}
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
expect(wrapper.vm).toBeDefined()
|
|
122
|
-
await waitRAF()
|
|
123
|
-
|
|
124
|
-
// Main outer wrapper (has z-index, etc.)... The stacker <div>
|
|
125
|
-
expect(wrapper.element.tagName).toBe('DIV')
|
|
126
|
-
expect(wrapper.classes().length).toBe(0)
|
|
127
|
-
expect(wrapper.element.style.position).toEqual('absolute')
|
|
128
|
-
expect(wrapper.element.style.zIndex).toEqual(`${DEFAULT_ZINDEX}`)
|
|
129
|
-
|
|
130
|
-
// Main modal wrapper
|
|
131
|
-
const $modal = wrapper.find('div.modal')
|
|
132
|
-
expect($modal.exists()).toBe(true)
|
|
133
|
-
expect($modal.attributes('id')).toBeDefined()
|
|
134
|
-
expect($modal.attributes('id')).toEqual('test')
|
|
135
|
-
expect($modal.attributes('role')).toBeDefined()
|
|
136
|
-
expect($modal.attributes('role')).toEqual('dialog')
|
|
137
|
-
expect($modal.attributes('aria-hidden')).toBeUndefined()
|
|
138
|
-
expect($modal.attributes('aria-modal')).toBeDefined()
|
|
139
|
-
expect($modal.attributes('aria-modal')).toEqual('true')
|
|
140
|
-
expect($modal.classes()).toContain('modal')
|
|
141
|
-
expect($modal.element.style.display).toEqual('')
|
|
142
|
-
|
|
143
|
-
// Should have a backdrop
|
|
144
|
-
const $backdrop = wrapper.find('div.modal-backdrop')
|
|
145
|
-
expect($backdrop.exists()).toBe(true)
|
|
146
|
-
|
|
147
|
-
// Modal dialog wrapper
|
|
148
|
-
const $dialog = $modal.find('div.modal-dialog')
|
|
149
|
-
expect($dialog.exists()).toBe(true)
|
|
150
|
-
|
|
151
|
-
// Modal content wrapper
|
|
152
|
-
const $content = $dialog.find('div.modal-content')
|
|
153
|
-
expect($content.exists()).toBe(true)
|
|
154
|
-
expect($content.attributes('tabindex')).toBeDefined()
|
|
155
|
-
expect($content.attributes('tabindex')).toEqual('-1')
|
|
156
|
-
|
|
157
|
-
wrapper.destroy()
|
|
158
|
-
})
|
|
159
|
-
|
|
160
|
-
it('renders appended to body when initially open and not static', async () => {
|
|
161
|
-
const wrapper = mount(BModal, {
|
|
162
|
-
attachTo: document.body,
|
|
163
|
-
propsData: {
|
|
164
|
-
static: false,
|
|
165
|
-
id: 'test-target',
|
|
166
|
-
visible: true
|
|
167
|
-
}
|
|
168
|
-
})
|
|
169
|
-
|
|
170
|
-
expect(wrapper.vm).toBeDefined()
|
|
171
|
-
|
|
172
|
-
await waitRAF()
|
|
173
|
-
expect(wrapper.element.nodeType).toEqual(Node.COMMENT_NODE)
|
|
174
|
-
|
|
175
|
-
const outer = document.getElementById('test-target___BV_modal_outer_')
|
|
176
|
-
expect(outer).toBeDefined()
|
|
177
|
-
expect(outer).not.toBe(null)
|
|
178
|
-
|
|
179
|
-
expect(getInstanceFromVNode(outer)).toBeDefined() // Target
|
|
180
|
-
if (!isVue3) {
|
|
181
|
-
expect(getInstanceFromVNode(outer).$options.name).toBe('BVTransporterTarget')
|
|
182
|
-
}
|
|
183
|
-
expect(outer.parentElement).toBeDefined()
|
|
184
|
-
expect(outer.parentElement).toBe(document.body)
|
|
185
|
-
|
|
186
|
-
// Destroy modal
|
|
187
|
-
wrapper.destroy()
|
|
188
|
-
|
|
189
|
-
await waitNT(wrapper.vm)
|
|
190
|
-
await waitRAF()
|
|
191
|
-
|
|
192
|
-
// Should no longer be in document
|
|
193
|
-
expect(outer.parentElement).toEqual(null)
|
|
194
|
-
})
|
|
195
|
-
|
|
196
|
-
it('has expected structure when closed after being initially open', async () => {
|
|
197
|
-
const wrapper = mount(BModal, {
|
|
198
|
-
attachTo: document.body,
|
|
199
|
-
propsData: {
|
|
200
|
-
static: true,
|
|
201
|
-
id: 'test',
|
|
202
|
-
visible: true
|
|
203
|
-
}
|
|
204
|
-
})
|
|
205
|
-
|
|
206
|
-
expect(wrapper.vm).toBeDefined()
|
|
207
|
-
|
|
208
|
-
await waitNT(wrapper.vm)
|
|
209
|
-
await waitRAF()
|
|
210
|
-
|
|
211
|
-
// Main outer wrapper (has z-index, etc.)... The stacker <div>
|
|
212
|
-
expect(wrapper.element.tagName).toBe('DIV')
|
|
213
|
-
expect(wrapper.classes().length).toBe(0)
|
|
214
|
-
expect(wrapper.element.style.position).toEqual('absolute')
|
|
215
|
-
expect(wrapper.element.style.zIndex).toEqual(`${DEFAULT_ZINDEX}`)
|
|
216
|
-
|
|
217
|
-
// Main modal wrapper
|
|
218
|
-
const $modal = wrapper.find('div.modal')
|
|
219
|
-
expect($modal.exists()).toBe(true)
|
|
220
|
-
expect($modal.attributes('aria-hidden')).toBeUndefined()
|
|
221
|
-
expect($modal.attributes('aria-modal')).toBeDefined()
|
|
222
|
-
expect($modal.attributes('aria-modal')).toEqual('true')
|
|
223
|
-
expect($modal.element.style.display).toEqual('')
|
|
224
|
-
|
|
225
|
-
// Should have a backdrop
|
|
226
|
-
const $backdrop = wrapper.find('div.modal-backdrop')
|
|
227
|
-
expect($backdrop.exists()).toBe(true)
|
|
228
|
-
|
|
229
|
-
// Now we close the modal via the value prop
|
|
230
|
-
await wrapper.setProps({
|
|
231
|
-
visible: false
|
|
232
|
-
})
|
|
233
|
-
await waitNT(wrapper.vm)
|
|
234
|
-
await waitRAF()
|
|
235
|
-
await waitNT(wrapper.vm)
|
|
236
|
-
await waitRAF()
|
|
237
|
-
|
|
238
|
-
expect($modal.attributes('aria-hidden')).toBeDefined()
|
|
239
|
-
expect($modal.attributes('aria-hidden')).toEqual('true')
|
|
240
|
-
expect($modal.attributes('aria-modal')).toBeUndefined()
|
|
241
|
-
expect($modal.element.style.display).toEqual('none')
|
|
242
|
-
|
|
243
|
-
// Backdrop should be removed
|
|
244
|
-
expect(wrapper.find('div.modal-backdrop').exists()).toBe(false)
|
|
245
|
-
|
|
246
|
-
wrapper.destroy()
|
|
247
|
-
})
|
|
248
|
-
|
|
249
|
-
it('title-html prop works', async () => {
|
|
250
|
-
const wrapper = mount(BModal, {
|
|
251
|
-
attachTo: document.body,
|
|
252
|
-
propsData: {
|
|
253
|
-
static: true,
|
|
254
|
-
id: 'test',
|
|
255
|
-
titleHtml: '<em>title</em>'
|
|
256
|
-
}
|
|
257
|
-
})
|
|
258
|
-
|
|
259
|
-
expect(wrapper.vm).toBeDefined()
|
|
260
|
-
|
|
261
|
-
// Modal title
|
|
262
|
-
const $title = wrapper.find('.modal-title')
|
|
263
|
-
expect($title.exists()).toBe(true)
|
|
264
|
-
expect($title.html()).toContain('<em>title</em>')
|
|
265
|
-
|
|
266
|
-
wrapper.destroy()
|
|
267
|
-
})
|
|
268
|
-
|
|
269
|
-
it('has correct header tag when "header-tag" prop is set', async () => {
|
|
270
|
-
const wrapper = mount(BModal, {
|
|
271
|
-
attachTo: document.body,
|
|
272
|
-
propsData: {
|
|
273
|
-
static: true,
|
|
274
|
-
id: 'test',
|
|
275
|
-
headerTag: 'div'
|
|
276
|
-
}
|
|
277
|
-
})
|
|
278
|
-
|
|
279
|
-
expect(wrapper.vm).toBeDefined()
|
|
280
|
-
await waitNT(wrapper.vm)
|
|
281
|
-
await waitRAF()
|
|
282
|
-
|
|
283
|
-
const $header = wrapper.find('.modal-header')
|
|
284
|
-
expect($header.exists()).toBe(true)
|
|
285
|
-
expect($header.element.tagName).toBe('DIV')
|
|
286
|
-
|
|
287
|
-
wrapper.destroy()
|
|
288
|
-
})
|
|
289
|
-
|
|
290
|
-
it('has correct footer tag when "footer-tag" prop is set', async () => {
|
|
291
|
-
const wrapper = mount(BModal, {
|
|
292
|
-
attachTo: document.body,
|
|
293
|
-
propsData: {
|
|
294
|
-
static: true,
|
|
295
|
-
id: 'test',
|
|
296
|
-
footerTag: 'div'
|
|
297
|
-
}
|
|
298
|
-
})
|
|
299
|
-
|
|
300
|
-
expect(wrapper.vm).toBeDefined()
|
|
301
|
-
await waitNT(wrapper.vm)
|
|
302
|
-
await waitRAF()
|
|
303
|
-
|
|
304
|
-
const $footer = wrapper.find('.modal-footer')
|
|
305
|
-
expect($footer.exists()).toBe(true)
|
|
306
|
-
expect($footer.element.tagName).toBe('DIV')
|
|
307
|
-
|
|
308
|
-
wrapper.destroy()
|
|
309
|
-
})
|
|
310
|
-
})
|
|
311
|
-
|
|
312
|
-
describe('default button content, classes and attributes', () => {
|
|
313
|
-
// We may want to move these tests into individual files for manageability
|
|
314
|
-
it('default footer ok and cancel buttons', async () => {
|
|
315
|
-
const wrapper = mount(BModal, {
|
|
316
|
-
attachTo: document.body,
|
|
317
|
-
propsData: {
|
|
318
|
-
static: true
|
|
319
|
-
}
|
|
320
|
-
})
|
|
321
|
-
expect(wrapper).toBeDefined()
|
|
322
|
-
|
|
323
|
-
const $buttons = wrapper.findAll('footer button')
|
|
324
|
-
expect($buttons.length).toBe(2)
|
|
325
|
-
|
|
326
|
-
// Cancel button (left-most button)
|
|
327
|
-
const $cancel = $buttons.at(0)
|
|
328
|
-
expect($cancel.attributes('type')).toBe('button')
|
|
329
|
-
expect($cancel.classes()).toContain('btn')
|
|
330
|
-
expect($cancel.classes()).toContain('btn-secondary')
|
|
331
|
-
expect($cancel.text()).toContain('Cancel')
|
|
332
|
-
|
|
333
|
-
// OK button (right-most button)
|
|
334
|
-
const $ok = $buttons.at(1)
|
|
335
|
-
expect($ok.attributes('type')).toBe('button')
|
|
336
|
-
expect($ok.classes()).toContain('btn')
|
|
337
|
-
expect($ok.classes()).toContain('btn-primary')
|
|
338
|
-
expect($ok.text()).toContain('OK')
|
|
339
|
-
|
|
340
|
-
wrapper.destroy()
|
|
341
|
-
})
|
|
342
|
-
|
|
343
|
-
it('default header close button', async () => {
|
|
344
|
-
const wrapper = mount(BModal, {
|
|
345
|
-
attachTo: document.body,
|
|
346
|
-
propsData: {
|
|
347
|
-
static: true
|
|
348
|
-
}
|
|
349
|
-
})
|
|
350
|
-
expect(wrapper).toBeDefined()
|
|
351
|
-
|
|
352
|
-
const $buttons = wrapper.findAll('header button')
|
|
353
|
-
expect($buttons.length).toBe(1)
|
|
354
|
-
|
|
355
|
-
// Close button
|
|
356
|
-
const $close = $buttons.at(0)
|
|
357
|
-
expect($close.attributes('type')).toBe('button')
|
|
358
|
-
expect($close.attributes('aria-label')).toBe('Close')
|
|
359
|
-
expect($close.classes()).toContain('close')
|
|
360
|
-
|
|
361
|
-
wrapper.destroy()
|
|
362
|
-
})
|
|
363
|
-
|
|
364
|
-
it('ok-title-html and cancel-title-html works', async () => {
|
|
365
|
-
const wrapper = mount(BModal, {
|
|
366
|
-
attachTo: document.body,
|
|
367
|
-
propsData: {
|
|
368
|
-
static: true,
|
|
369
|
-
okTitleHtml: '<em>ok</em>',
|
|
370
|
-
cancelTitleHtml: '<em>cancel</em>'
|
|
371
|
-
}
|
|
372
|
-
})
|
|
373
|
-
expect(wrapper).toBeDefined()
|
|
374
|
-
|
|
375
|
-
const $buttons = wrapper.findAll('footer button')
|
|
376
|
-
expect($buttons.length).toBe(2)
|
|
377
|
-
|
|
378
|
-
// Cancel button (left-most button)
|
|
379
|
-
const $cancel = $buttons.at(0)
|
|
380
|
-
expect($cancel.attributes('type')).toBe('button')
|
|
381
|
-
expect($cancel.text()).toContain('cancel')
|
|
382
|
-
// `v-html` is applied to a span
|
|
383
|
-
expect($cancel.html()).toContain('<em>cancel</em>')
|
|
384
|
-
|
|
385
|
-
// OK button (right-most button)
|
|
386
|
-
const $ok = $buttons.at(1)
|
|
387
|
-
expect($ok.attributes('type')).toBe('button')
|
|
388
|
-
expect($ok.text()).toContain('ok')
|
|
389
|
-
// `v-html` is applied to a span
|
|
390
|
-
expect($ok.html()).toContain('<em>ok</em>')
|
|
391
|
-
|
|
392
|
-
wrapper.destroy()
|
|
393
|
-
})
|
|
394
|
-
|
|
395
|
-
it('modal-ok and modal-cancel button content slots works', async () => {
|
|
396
|
-
const wrapper = mount(BModal, {
|
|
397
|
-
attachTo: document.body,
|
|
398
|
-
propsData: {
|
|
399
|
-
static: true
|
|
400
|
-
},
|
|
401
|
-
slots: {
|
|
402
|
-
'modal-ok': '<em>bar ok</em>',
|
|
403
|
-
'modal-cancel': '<em>foo cancel</em>'
|
|
404
|
-
}
|
|
405
|
-
})
|
|
406
|
-
expect(wrapper).toBeDefined()
|
|
407
|
-
|
|
408
|
-
const $buttons = wrapper.findAll('footer button')
|
|
409
|
-
expect($buttons.length).toBe(2)
|
|
410
|
-
|
|
411
|
-
// Cancel button (left-most button)
|
|
412
|
-
const $cancel = $buttons.at(0)
|
|
413
|
-
expect($cancel.attributes('type')).toBe('button')
|
|
414
|
-
expect($cancel.text()).toContain('foo cancel')
|
|
415
|
-
// `v-html` is applied to a span
|
|
416
|
-
expect($cancel.html()).toContain('<em>foo cancel</em>')
|
|
417
|
-
|
|
418
|
-
// OK button (right-most button)
|
|
419
|
-
const $ok = $buttons.at(1)
|
|
420
|
-
expect($ok.attributes('type')).toBe('button')
|
|
421
|
-
expect($ok.text()).toContain('bar ok')
|
|
422
|
-
// `v-html` is applied to a span
|
|
423
|
-
expect($ok.html()).toContain('<em>bar ok</em>')
|
|
424
|
-
|
|
425
|
-
wrapper.destroy()
|
|
426
|
-
})
|
|
427
|
-
})
|
|
428
|
-
|
|
429
|
-
describe('button and event functionality', () => {
|
|
430
|
-
it('header close button triggers modal close and is preventable', async () => {
|
|
431
|
-
let cancelHide = true
|
|
432
|
-
let trigger = null
|
|
433
|
-
let event = null
|
|
434
|
-
const wrapper = mount(BModal, {
|
|
435
|
-
attachTo: document.body,
|
|
436
|
-
propsData: {
|
|
437
|
-
static: true,
|
|
438
|
-
id: 'test',
|
|
439
|
-
visible: true
|
|
440
|
-
},
|
|
441
|
-
listeners: {
|
|
442
|
-
hide: bvEvent => {
|
|
443
|
-
if (cancelHide) {
|
|
444
|
-
bvEvent.preventDefault()
|
|
445
|
-
}
|
|
446
|
-
trigger = bvEvent.trigger
|
|
447
|
-
event = bvEvent
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
})
|
|
451
|
-
|
|
452
|
-
expect(wrapper.vm).toBeDefined()
|
|
453
|
-
|
|
454
|
-
await waitNT(wrapper.vm)
|
|
455
|
-
await waitRAF()
|
|
456
|
-
await waitNT(wrapper.vm)
|
|
457
|
-
await waitRAF()
|
|
458
|
-
|
|
459
|
-
const $modal = wrapper.find('div.modal')
|
|
460
|
-
expect($modal.exists()).toBe(true)
|
|
461
|
-
|
|
462
|
-
expect($modal.element.style.display).toEqual('')
|
|
463
|
-
|
|
464
|
-
const $buttons = wrapper.findAll('header button')
|
|
465
|
-
expect($buttons.length).toBe(1)
|
|
466
|
-
|
|
467
|
-
// Close button
|
|
468
|
-
const $close = $buttons.at(0)
|
|
469
|
-
expect($close.attributes('type')).toBe('button')
|
|
470
|
-
expect($close.attributes('aria-label')).toBe('Close')
|
|
471
|
-
expect($close.classes()).toContain('close')
|
|
472
|
-
|
|
473
|
-
expect(wrapper.emitted('hide')).toBeUndefined()
|
|
474
|
-
expect(trigger).toEqual(null)
|
|
475
|
-
expect(event).toEqual(null)
|
|
476
|
-
|
|
477
|
-
// Try and close modal (but we prevent it)
|
|
478
|
-
await $close.trigger('click')
|
|
479
|
-
expect(trigger).toEqual('headerclose')
|
|
480
|
-
expect(event).toBeInstanceOf(BvModalEvent)
|
|
481
|
-
|
|
482
|
-
await waitNT(wrapper.vm)
|
|
483
|
-
await waitRAF()
|
|
484
|
-
await waitNT(wrapper.vm)
|
|
485
|
-
await waitRAF()
|
|
486
|
-
|
|
487
|
-
// Modal should still be open
|
|
488
|
-
expect($modal.element.style.display).toEqual('')
|
|
489
|
-
|
|
490
|
-
// Try and close modal (and not prevent it)
|
|
491
|
-
cancelHide = false
|
|
492
|
-
trigger = null
|
|
493
|
-
event = null
|
|
494
|
-
await $close.trigger('click')
|
|
495
|
-
expect(trigger).toEqual('headerclose')
|
|
496
|
-
expect(event).toBeInstanceOf(BvModalEvent)
|
|
497
|
-
|
|
498
|
-
await waitNT(wrapper.vm)
|
|
499
|
-
await waitRAF()
|
|
500
|
-
await waitNT(wrapper.vm)
|
|
501
|
-
await waitRAF()
|
|
502
|
-
|
|
503
|
-
// Modal should now be closed
|
|
504
|
-
expect($modal.element.style.display).toEqual('none')
|
|
505
|
-
|
|
506
|
-
wrapper.destroy()
|
|
507
|
-
})
|
|
508
|
-
|
|
509
|
-
it('footer OK and CANCEL buttons trigger modal close and are preventable', async () => {
|
|
510
|
-
let cancelHide = true
|
|
511
|
-
let trigger = null
|
|
512
|
-
const wrapper = mount(BModal, {
|
|
513
|
-
attachTo: document.body,
|
|
514
|
-
propsData: {
|
|
515
|
-
static: true,
|
|
516
|
-
id: 'test',
|
|
517
|
-
visible: true
|
|
518
|
-
},
|
|
519
|
-
listeners: {
|
|
520
|
-
hide: bvEvent => {
|
|
521
|
-
if (cancelHide) {
|
|
522
|
-
bvEvent.preventDefault()
|
|
523
|
-
}
|
|
524
|
-
trigger = bvEvent.trigger
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
})
|
|
528
|
-
|
|
529
|
-
expect(wrapper.vm).toBeDefined()
|
|
530
|
-
|
|
531
|
-
await waitNT(wrapper.vm)
|
|
532
|
-
await waitRAF()
|
|
533
|
-
await waitNT(wrapper.vm)
|
|
534
|
-
await waitRAF()
|
|
535
|
-
|
|
536
|
-
const $modal = wrapper.find('div.modal')
|
|
537
|
-
expect($modal.exists()).toBe(true)
|
|
538
|
-
|
|
539
|
-
expect($modal.element.style.display).toEqual('')
|
|
540
|
-
|
|
541
|
-
const $buttons = wrapper.findAll('footer button')
|
|
542
|
-
expect($buttons.length).toBe(2)
|
|
543
|
-
|
|
544
|
-
// Cancel button (left-most button)
|
|
545
|
-
const $cancel = $buttons.at(0)
|
|
546
|
-
expect($cancel.text()).toContain('Cancel')
|
|
547
|
-
|
|
548
|
-
// OK button (right-most button)
|
|
549
|
-
const $ok = $buttons.at(1)
|
|
550
|
-
expect($ok.text()).toContain('OK')
|
|
551
|
-
|
|
552
|
-
expect(wrapper.emitted('hide')).toBeUndefined()
|
|
553
|
-
expect(trigger).toEqual(null)
|
|
554
|
-
|
|
555
|
-
// Try and close modal (but we prevent it)
|
|
556
|
-
await $ok.trigger('click')
|
|
557
|
-
expect(trigger).toEqual('ok')
|
|
558
|
-
|
|
559
|
-
await waitNT(wrapper.vm)
|
|
560
|
-
await waitRAF()
|
|
561
|
-
await waitNT(wrapper.vm)
|
|
562
|
-
await waitRAF()
|
|
563
|
-
|
|
564
|
-
// Modal should still be open
|
|
565
|
-
expect($modal.element.style.display).toEqual('')
|
|
566
|
-
|
|
567
|
-
// Try and close modal (and not prevent it)
|
|
568
|
-
cancelHide = false
|
|
569
|
-
trigger = null
|
|
570
|
-
await $cancel.trigger('click')
|
|
571
|
-
expect(trigger).toEqual('cancel')
|
|
572
|
-
|
|
573
|
-
await waitNT(wrapper.vm)
|
|
574
|
-
await waitRAF()
|
|
575
|
-
await waitNT(wrapper.vm)
|
|
576
|
-
await waitRAF()
|
|
577
|
-
await waitNT(wrapper.vm)
|
|
578
|
-
|
|
579
|
-
// Modal should now be closed
|
|
580
|
-
expect($modal.element.style.display).toEqual('none')
|
|
581
|
-
|
|
582
|
-
// Modal should have emitted these events
|
|
583
|
-
expect(wrapper.emitted('ok')).toBeDefined()
|
|
584
|
-
expect(wrapper.emitted('ok').length).toBe(1)
|
|
585
|
-
expect(wrapper.emitted('cancel')).toBeDefined()
|
|
586
|
-
expect(wrapper.emitted('cancel').length).toBe(1)
|
|
587
|
-
expect(wrapper.emitted('hidden')).toBeDefined()
|
|
588
|
-
expect(wrapper.emitted('hidden').length).toBe(1)
|
|
589
|
-
|
|
590
|
-
wrapper.destroy()
|
|
591
|
-
})
|
|
592
|
-
|
|
593
|
-
it('pressing ESC closes modal', async () => {
|
|
594
|
-
let trigger = null
|
|
595
|
-
const wrapper = mount(BModal, {
|
|
596
|
-
attachTo: document.body,
|
|
597
|
-
propsData: {
|
|
598
|
-
static: true,
|
|
599
|
-
id: 'test',
|
|
600
|
-
visible: true
|
|
601
|
-
},
|
|
602
|
-
listeners: {
|
|
603
|
-
hide: bvEvent => {
|
|
604
|
-
trigger = bvEvent.trigger
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
})
|
|
608
|
-
|
|
609
|
-
expect(wrapper.vm).toBeDefined()
|
|
610
|
-
|
|
611
|
-
await waitNT(wrapper.vm)
|
|
612
|
-
await waitRAF()
|
|
613
|
-
await waitNT(wrapper.vm)
|
|
614
|
-
await waitRAF()
|
|
615
|
-
|
|
616
|
-
const $modal = wrapper.find('div.modal')
|
|
617
|
-
expect($modal.exists()).toBe(true)
|
|
618
|
-
|
|
619
|
-
expect($modal.element.style.display).toEqual('')
|
|
620
|
-
|
|
621
|
-
expect(wrapper.emitted('hide')).toBeUndefined()
|
|
622
|
-
expect(trigger).toEqual(null)
|
|
623
|
-
|
|
624
|
-
// Try and close modal via ESC
|
|
625
|
-
await $modal.trigger('keydown.esc')
|
|
626
|
-
expect(trigger).toEqual('esc')
|
|
627
|
-
|
|
628
|
-
await waitNT(wrapper.vm)
|
|
629
|
-
await waitRAF()
|
|
630
|
-
await waitNT(wrapper.vm)
|
|
631
|
-
await waitRAF()
|
|
632
|
-
await waitNT(wrapper.vm)
|
|
633
|
-
|
|
634
|
-
// Modal should now be closed
|
|
635
|
-
expect($modal.element.style.display).toEqual('none')
|
|
636
|
-
|
|
637
|
-
// Modal should have emitted these events
|
|
638
|
-
expect(wrapper.emitted('hide')).toBeDefined()
|
|
639
|
-
expect(wrapper.emitted('hide').length).toBe(1)
|
|
640
|
-
expect(wrapper.emitted('hidden')).toBeDefined()
|
|
641
|
-
expect(wrapper.emitted('hidden').length).toBe(1)
|
|
642
|
-
|
|
643
|
-
expect(wrapper.emitted('ok')).toBeUndefined()
|
|
644
|
-
expect(wrapper.emitted('cancel')).toBeUndefined()
|
|
645
|
-
|
|
646
|
-
wrapper.destroy()
|
|
647
|
-
})
|
|
648
|
-
|
|
649
|
-
it('click outside closes modal', async () => {
|
|
650
|
-
let trigger = null
|
|
651
|
-
const wrapper = mount(BModal, {
|
|
652
|
-
attachTo: document.body,
|
|
653
|
-
propsData: {
|
|
654
|
-
static: true,
|
|
655
|
-
id: 'test',
|
|
656
|
-
visible: true
|
|
657
|
-
},
|
|
658
|
-
listeners: {
|
|
659
|
-
hide: bvEvent => {
|
|
660
|
-
trigger = bvEvent.trigger
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
})
|
|
664
|
-
|
|
665
|
-
expect(wrapper.vm).toBeDefined()
|
|
666
|
-
|
|
667
|
-
await waitNT(wrapper.vm)
|
|
668
|
-
await waitRAF()
|
|
669
|
-
await waitNT(wrapper.vm)
|
|
670
|
-
await waitRAF()
|
|
671
|
-
|
|
672
|
-
const $modal = wrapper.find('div.modal')
|
|
673
|
-
expect($modal.exists()).toBe(true)
|
|
674
|
-
|
|
675
|
-
expect($modal.element.style.display).toEqual('')
|
|
676
|
-
|
|
677
|
-
expect(wrapper.emitted('hide')).toBeUndefined()
|
|
678
|
-
expect(trigger).toEqual(null)
|
|
679
|
-
|
|
680
|
-
// Try and close modal via click out
|
|
681
|
-
await $modal.trigger('click')
|
|
682
|
-
expect(trigger).toEqual('backdrop')
|
|
683
|
-
|
|
684
|
-
await waitNT(wrapper.vm)
|
|
685
|
-
await waitRAF()
|
|
686
|
-
await waitNT(wrapper.vm)
|
|
687
|
-
await waitRAF()
|
|
688
|
-
await waitNT(wrapper.vm)
|
|
689
|
-
|
|
690
|
-
// Modal should now be closed
|
|
691
|
-
expect($modal.element.style.display).toEqual('none')
|
|
692
|
-
|
|
693
|
-
// Modal should have emitted these events
|
|
694
|
-
expect(wrapper.emitted('hide')).toBeDefined()
|
|
695
|
-
expect(wrapper.emitted('hide').length).toBe(1)
|
|
696
|
-
expect(wrapper.emitted('hidden')).toBeDefined()
|
|
697
|
-
expect(wrapper.emitted('hidden').length).toBe(1)
|
|
698
|
-
|
|
699
|
-
expect(wrapper.emitted('ok')).toBeUndefined()
|
|
700
|
-
expect(wrapper.emitted('cancel')).toBeUndefined()
|
|
701
|
-
|
|
702
|
-
wrapper.destroy()
|
|
703
|
-
})
|
|
704
|
-
|
|
705
|
-
it('mousedown inside followed by mouse up outside (click) does not close modal', async () => {
|
|
706
|
-
let trigger = null
|
|
707
|
-
let called = false
|
|
708
|
-
const wrapper = mount(BModal, {
|
|
709
|
-
attachTo: document.body,
|
|
710
|
-
propsData: {
|
|
711
|
-
static: true,
|
|
712
|
-
id: 'test',
|
|
713
|
-
visible: true
|
|
714
|
-
},
|
|
715
|
-
listeners: {
|
|
716
|
-
hide: bvEvent => {
|
|
717
|
-
called = true
|
|
718
|
-
trigger = bvEvent.trigger
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
})
|
|
722
|
-
|
|
723
|
-
expect(wrapper.vm).toBeDefined()
|
|
724
|
-
|
|
725
|
-
await waitNT(wrapper.vm)
|
|
726
|
-
await waitRAF()
|
|
727
|
-
await waitNT(wrapper.vm)
|
|
728
|
-
await waitRAF()
|
|
729
|
-
|
|
730
|
-
const $modal = wrapper.find('div.modal')
|
|
731
|
-
expect($modal.exists()).toBe(true)
|
|
732
|
-
|
|
733
|
-
const $dialog = wrapper.find('div.modal-dialog')
|
|
734
|
-
expect($dialog.exists()).toBe(true)
|
|
735
|
-
|
|
736
|
-
const $footer = wrapper.find('footer.modal-footer')
|
|
737
|
-
expect($footer.exists()).toBe(true)
|
|
738
|
-
|
|
739
|
-
expect($modal.element.style.display).toEqual('')
|
|
740
|
-
|
|
741
|
-
expect(wrapper.emitted('hide')).toBeUndefined()
|
|
742
|
-
expect(trigger).toEqual(null)
|
|
743
|
-
|
|
744
|
-
// Try and close modal via a "dragged" click out
|
|
745
|
-
// starting from inside modal and finishing on backdrop
|
|
746
|
-
await $dialog.trigger('mousedown')
|
|
747
|
-
await $modal.trigger('mouseup')
|
|
748
|
-
await $modal.trigger('click')
|
|
749
|
-
await waitRAF()
|
|
750
|
-
await waitRAF()
|
|
751
|
-
expect(called).toEqual(false)
|
|
752
|
-
expect(trigger).toEqual(null)
|
|
753
|
-
|
|
754
|
-
// Modal should not be closed
|
|
755
|
-
expect($modal.element.style.display).toEqual('')
|
|
756
|
-
|
|
757
|
-
// Try and close modal via a "dragged" click out
|
|
758
|
-
// starting from inside modal and finishing on backdrop
|
|
759
|
-
await $footer.trigger('mousedown')
|
|
760
|
-
await $modal.trigger('mouseup')
|
|
761
|
-
await $modal.trigger('click')
|
|
762
|
-
await waitRAF()
|
|
763
|
-
await waitRAF()
|
|
764
|
-
expect(called).toEqual(false)
|
|
765
|
-
expect(trigger).toEqual(null)
|
|
766
|
-
|
|
767
|
-
// Modal should not be closed
|
|
768
|
-
expect($modal.element.style.display).toEqual('')
|
|
769
|
-
|
|
770
|
-
// Try and close modal via click out
|
|
771
|
-
await $modal.trigger('click')
|
|
772
|
-
await waitRAF()
|
|
773
|
-
await waitRAF()
|
|
774
|
-
expect(called).toEqual(true)
|
|
775
|
-
expect(trigger).toEqual('backdrop')
|
|
776
|
-
|
|
777
|
-
// Modal should now be closed
|
|
778
|
-
expect($modal.element.style.display).toEqual('none')
|
|
779
|
-
|
|
780
|
-
wrapper.destroy()
|
|
781
|
-
})
|
|
782
|
-
|
|
783
|
-
it('$root bv::show::modal and bv::hide::modal work', async () => {
|
|
784
|
-
const wrapper = mount(BModal, {
|
|
785
|
-
attachTo: document.body,
|
|
786
|
-
propsData: {
|
|
787
|
-
static: true,
|
|
788
|
-
id: 'test',
|
|
789
|
-
visible: false
|
|
790
|
-
}
|
|
791
|
-
})
|
|
792
|
-
|
|
793
|
-
expect(wrapper.vm).toBeDefined()
|
|
794
|
-
|
|
795
|
-
await waitNT(wrapper.vm)
|
|
796
|
-
await waitRAF()
|
|
797
|
-
await waitNT(wrapper.vm)
|
|
798
|
-
await waitRAF()
|
|
799
|
-
|
|
800
|
-
const $modal = wrapper.find('div.modal')
|
|
801
|
-
expect($modal.exists()).toBe(true)
|
|
802
|
-
|
|
803
|
-
expect($modal.element.style.display).toEqual('none')
|
|
804
|
-
|
|
805
|
-
// Try and open modal via `bv::show::modal`
|
|
806
|
-
wrapper.vm.$root.$emit('bv::show::modal', 'test')
|
|
807
|
-
|
|
808
|
-
await waitNT(wrapper.vm)
|
|
809
|
-
await waitRAF()
|
|
810
|
-
await waitNT(wrapper.vm)
|
|
811
|
-
await waitRAF()
|
|
812
|
-
|
|
813
|
-
// Modal should now be open
|
|
814
|
-
expect($modal.element.style.display).toEqual('')
|
|
815
|
-
|
|
816
|
-
// Try and close modal via `bv::hide::modal`
|
|
817
|
-
wrapper.vm.$root.$emit('bv::hide::modal', 'test')
|
|
818
|
-
|
|
819
|
-
await waitNT(wrapper.vm)
|
|
820
|
-
await waitRAF()
|
|
821
|
-
await waitNT(wrapper.vm)
|
|
822
|
-
await waitRAF()
|
|
823
|
-
|
|
824
|
-
// Modal should now be closed
|
|
825
|
-
expect($modal.element.style.display).toEqual('none')
|
|
826
|
-
|
|
827
|
-
wrapper.destroy()
|
|
828
|
-
})
|
|
829
|
-
|
|
830
|
-
it('$root bv::toggle::modal works', async () => {
|
|
831
|
-
const wrapper = mount(BModal, {
|
|
832
|
-
attachTo: document.body,
|
|
833
|
-
propsData: {
|
|
834
|
-
static: true,
|
|
835
|
-
id: 'test',
|
|
836
|
-
visible: false
|
|
837
|
-
}
|
|
838
|
-
})
|
|
839
|
-
|
|
840
|
-
expect(wrapper.vm).toBeDefined()
|
|
841
|
-
|
|
842
|
-
await waitNT(wrapper.vm)
|
|
843
|
-
await waitRAF()
|
|
844
|
-
await waitNT(wrapper.vm)
|
|
845
|
-
await waitRAF()
|
|
846
|
-
|
|
847
|
-
const $modal = wrapper.find('div.modal')
|
|
848
|
-
expect($modal.exists()).toBe(true)
|
|
849
|
-
|
|
850
|
-
expect($modal.element.style.display).toEqual('none')
|
|
851
|
-
|
|
852
|
-
// Try and open modal via `bv::toggle::modal`
|
|
853
|
-
wrapper.vm.$root.$emit('bv::toggle::modal', 'test')
|
|
854
|
-
|
|
855
|
-
await waitNT(wrapper.vm)
|
|
856
|
-
await waitRAF()
|
|
857
|
-
await waitNT(wrapper.vm)
|
|
858
|
-
await waitRAF()
|
|
859
|
-
|
|
860
|
-
// Modal should now be open
|
|
861
|
-
expect($modal.element.style.display).toEqual('')
|
|
862
|
-
|
|
863
|
-
// Try and close modal via `bv::toggle::modal`
|
|
864
|
-
wrapper.vm.$root.$emit('bv::toggle::modal', 'test')
|
|
865
|
-
|
|
866
|
-
await waitNT(wrapper.vm)
|
|
867
|
-
await waitRAF()
|
|
868
|
-
await waitNT(wrapper.vm)
|
|
869
|
-
await waitRAF()
|
|
870
|
-
|
|
871
|
-
// Modal should now be closed
|
|
872
|
-
expect($modal.element.style.display).toEqual('none')
|
|
873
|
-
|
|
874
|
-
// Try and open modal via `bv::toggle::modal` with wrong ID
|
|
875
|
-
wrapper.vm.$root.$emit('bv::toggle::modal', 'not-test')
|
|
876
|
-
|
|
877
|
-
await waitNT(wrapper.vm)
|
|
878
|
-
await waitRAF()
|
|
879
|
-
await waitNT(wrapper.vm)
|
|
880
|
-
await waitRAF()
|
|
881
|
-
|
|
882
|
-
// Modal should now be open
|
|
883
|
-
expect($modal.element.style.display).toEqual('none')
|
|
884
|
-
|
|
885
|
-
wrapper.destroy()
|
|
886
|
-
})
|
|
887
|
-
|
|
888
|
-
it('show event is cancellable', async () => {
|
|
889
|
-
let prevent = true
|
|
890
|
-
let called = 0
|
|
891
|
-
const wrapper = mount(BModal, {
|
|
892
|
-
attachTo: document.body,
|
|
893
|
-
propsData: {
|
|
894
|
-
static: true,
|
|
895
|
-
id: 'test',
|
|
896
|
-
visible: false
|
|
897
|
-
}
|
|
898
|
-
})
|
|
899
|
-
|
|
900
|
-
expect(wrapper.vm).toBeDefined()
|
|
901
|
-
|
|
902
|
-
await waitNT(wrapper.vm)
|
|
903
|
-
await waitRAF()
|
|
904
|
-
await waitNT(wrapper.vm)
|
|
905
|
-
await waitRAF()
|
|
906
|
-
|
|
907
|
-
const $modal = wrapper.find('div.modal')
|
|
908
|
-
expect($modal.exists()).toBe(true)
|
|
909
|
-
|
|
910
|
-
expect($modal.element.style.display).toEqual('none')
|
|
911
|
-
|
|
912
|
-
wrapper.vm.$on('show', bvEvent => {
|
|
913
|
-
called = true
|
|
914
|
-
if (prevent) {
|
|
915
|
-
bvEvent.preventDefault()
|
|
916
|
-
}
|
|
917
|
-
})
|
|
918
|
-
|
|
919
|
-
// Try and open modal via `bv::show::modal`
|
|
920
|
-
wrapper.vm.$root.$emit('bv::show::modal', 'test')
|
|
921
|
-
|
|
922
|
-
await waitNT(wrapper.vm)
|
|
923
|
-
await waitRAF()
|
|
924
|
-
await waitNT(wrapper.vm)
|
|
925
|
-
await waitRAF()
|
|
926
|
-
|
|
927
|
-
// Modal should not open
|
|
928
|
-
expect(called).toBe(true)
|
|
929
|
-
expect($modal.element.style.display).toEqual('none')
|
|
930
|
-
|
|
931
|
-
await waitNT(wrapper.vm)
|
|
932
|
-
await waitRAF()
|
|
933
|
-
await waitNT(wrapper.vm)
|
|
934
|
-
await waitRAF()
|
|
935
|
-
|
|
936
|
-
// Allow modal to open
|
|
937
|
-
prevent = false
|
|
938
|
-
called = false
|
|
939
|
-
|
|
940
|
-
// Try and open modal via `bv::show::modal`
|
|
941
|
-
wrapper.vm.$root.$emit('bv::show::modal', 'test')
|
|
942
|
-
|
|
943
|
-
await waitNT(wrapper.vm)
|
|
944
|
-
await waitRAF()
|
|
945
|
-
await waitNT(wrapper.vm)
|
|
946
|
-
await waitRAF()
|
|
947
|
-
|
|
948
|
-
// Modal should now be open
|
|
949
|
-
expect(called).toBe(true)
|
|
950
|
-
expect($modal.element.style.display).toEqual('')
|
|
951
|
-
|
|
952
|
-
wrapper.destroy()
|
|
953
|
-
})
|
|
954
|
-
|
|
955
|
-
it('instance .toggle() methods works', async () => {
|
|
956
|
-
const wrapper = mount(BModal, {
|
|
957
|
-
attachTo: document.body,
|
|
958
|
-
propsData: {
|
|
959
|
-
static: true,
|
|
960
|
-
id: 'test',
|
|
961
|
-
visible: false
|
|
962
|
-
}
|
|
963
|
-
})
|
|
964
|
-
|
|
965
|
-
expect(wrapper.vm).toBeDefined()
|
|
966
|
-
|
|
967
|
-
await waitNT(wrapper.vm)
|
|
968
|
-
await waitRAF()
|
|
969
|
-
await waitNT(wrapper.vm)
|
|
970
|
-
await waitRAF()
|
|
971
|
-
|
|
972
|
-
const $modal = wrapper.find('div.modal')
|
|
973
|
-
expect($modal.exists()).toBe(true)
|
|
974
|
-
|
|
975
|
-
expect($modal.element.style.display).toEqual('none')
|
|
976
|
-
|
|
977
|
-
// Try and open modal via `.toggle()` method
|
|
978
|
-
wrapper.vm.toggle()
|
|
979
|
-
|
|
980
|
-
await waitNT(wrapper.vm)
|
|
981
|
-
await waitRAF()
|
|
982
|
-
await waitNT(wrapper.vm)
|
|
983
|
-
await waitRAF()
|
|
984
|
-
|
|
985
|
-
// Modal should now be open
|
|
986
|
-
expect($modal.element.style.display).toEqual('')
|
|
987
|
-
|
|
988
|
-
// Try and close modal via `.toggle()` method
|
|
989
|
-
wrapper.vm.toggle()
|
|
990
|
-
|
|
991
|
-
await waitNT(wrapper.vm)
|
|
992
|
-
await waitRAF()
|
|
993
|
-
await waitNT(wrapper.vm)
|
|
994
|
-
await waitRAF()
|
|
995
|
-
|
|
996
|
-
// Modal should now be closed
|
|
997
|
-
expect($modal.element.style.display).toEqual('none')
|
|
998
|
-
|
|
999
|
-
wrapper.destroy()
|
|
1000
|
-
})
|
|
1001
|
-
|
|
1002
|
-
it('modal closes when no-stacking is true and another modal opens', async () => {
|
|
1003
|
-
const wrapper = mount(BModal, {
|
|
1004
|
-
attachTo: document.body,
|
|
1005
|
-
propsData: {
|
|
1006
|
-
static: true,
|
|
1007
|
-
id: 'test',
|
|
1008
|
-
visible: true,
|
|
1009
|
-
noStacking: true
|
|
1010
|
-
}
|
|
1011
|
-
})
|
|
1012
|
-
|
|
1013
|
-
expect(wrapper.vm).toBeDefined()
|
|
1014
|
-
|
|
1015
|
-
await waitNT(wrapper.vm)
|
|
1016
|
-
await waitRAF()
|
|
1017
|
-
await waitNT(wrapper.vm)
|
|
1018
|
-
await waitRAF()
|
|
1019
|
-
|
|
1020
|
-
const $modal = wrapper.find('div.modal')
|
|
1021
|
-
expect($modal.exists()).toBe(true)
|
|
1022
|
-
|
|
1023
|
-
expect($modal.element.style.display).toEqual('')
|
|
1024
|
-
|
|
1025
|
-
// Simulate an other modal opening (by emitting a fake BvEvent)
|
|
1026
|
-
// `bvEvent.vueTarget` is normally a Vue instance, but in this
|
|
1027
|
-
// case we just use a random object since we are checking inequality
|
|
1028
|
-
wrapper.vm.$root.$emit('bv::modal::show', { vueTarget: Number })
|
|
1029
|
-
|
|
1030
|
-
await waitNT(wrapper.vm)
|
|
1031
|
-
await waitRAF()
|
|
1032
|
-
await waitNT(wrapper.vm)
|
|
1033
|
-
await waitRAF()
|
|
1034
|
-
|
|
1035
|
-
// Modal should now be closed
|
|
1036
|
-
expect($modal.element.style.display).toEqual('none')
|
|
1037
|
-
|
|
1038
|
-
wrapper.destroy()
|
|
1039
|
-
})
|
|
1040
|
-
})
|
|
1041
|
-
|
|
1042
|
-
describe('focus management', () => {
|
|
1043
|
-
it('returns focus to previous active element when return focus not set and not using v-b-toggle', async () => {
|
|
1044
|
-
const App = {
|
|
1045
|
-
render(h) {
|
|
1046
|
-
return h('div', [
|
|
1047
|
-
h('button', { class: 'trigger', attrs: { id: 'trigger', type: 'button' } }, 'trigger'),
|
|
1048
|
-
h(BModal, { props: { static: true, id: 'test', visible: false } }, 'modal content')
|
|
1049
|
-
])
|
|
1050
|
-
}
|
|
1051
|
-
}
|
|
1052
|
-
const wrapper = mount(App, {
|
|
1053
|
-
attachTo: document.body
|
|
1054
|
-
})
|
|
1055
|
-
|
|
1056
|
-
expect(wrapper.vm).toBeDefined()
|
|
1057
|
-
|
|
1058
|
-
await waitNT(wrapper.vm)
|
|
1059
|
-
await waitRAF()
|
|
1060
|
-
await waitNT(wrapper.vm)
|
|
1061
|
-
await waitRAF()
|
|
1062
|
-
await waitNT(wrapper.vm)
|
|
1063
|
-
await waitNT(wrapper.vm)
|
|
1064
|
-
|
|
1065
|
-
const $button = wrapper.find('button.trigger')
|
|
1066
|
-
expect($button.exists()).toBe(true)
|
|
1067
|
-
expect($button.element.tagName).toBe('BUTTON')
|
|
1068
|
-
|
|
1069
|
-
const $modal = wrapper.find('div.modal')
|
|
1070
|
-
expect($modal.exists()).toBe(true)
|
|
1071
|
-
|
|
1072
|
-
expect($modal.element.style.display).toEqual('none')
|
|
1073
|
-
expect(document.activeElement).toBe(document.body)
|
|
1074
|
-
|
|
1075
|
-
// Set the active element to the button
|
|
1076
|
-
$button.element.focus()
|
|
1077
|
-
expect(document.activeElement).toBe($button.element)
|
|
1078
|
-
|
|
1079
|
-
// Try and open modal via `.toggle()` method
|
|
1080
|
-
wrapper.findComponent(BModal).vm.toggle()
|
|
1081
|
-
|
|
1082
|
-
await waitNT(wrapper.vm)
|
|
1083
|
-
await waitRAF()
|
|
1084
|
-
await waitNT(wrapper.vm)
|
|
1085
|
-
await waitRAF()
|
|
1086
|
-
await waitNT(wrapper.vm)
|
|
1087
|
-
await waitRAF()
|
|
1088
|
-
await waitNT(wrapper.vm)
|
|
1089
|
-
await waitRAF()
|
|
1090
|
-
|
|
1091
|
-
// Modal should now be open
|
|
1092
|
-
expect($modal.element.style.display).toEqual('')
|
|
1093
|
-
expect(document.activeElement).not.toBe(document.body)
|
|
1094
|
-
expect(document.activeElement).not.toBe($button.element)
|
|
1095
|
-
expect($modal.element.contains(document.activeElement)).toBe(true)
|
|
1096
|
-
|
|
1097
|
-
// Try and close modal via `.toggle()` method
|
|
1098
|
-
wrapper.findComponent(BModal).vm.toggle()
|
|
1099
|
-
|
|
1100
|
-
await waitNT(wrapper.vm)
|
|
1101
|
-
await waitRAF()
|
|
1102
|
-
await waitNT(wrapper.vm)
|
|
1103
|
-
await waitRAF()
|
|
1104
|
-
await waitNT(wrapper.vm)
|
|
1105
|
-
await waitRAF()
|
|
1106
|
-
await waitNT(wrapper.vm)
|
|
1107
|
-
await waitRAF()
|
|
1108
|
-
|
|
1109
|
-
// Modal should now be closed
|
|
1110
|
-
expect($modal.element.style.display).toEqual('none')
|
|
1111
|
-
expect(document.activeElement).toBe($button.element)
|
|
1112
|
-
|
|
1113
|
-
wrapper.destroy()
|
|
1114
|
-
})
|
|
1115
|
-
|
|
1116
|
-
it('returns focus to element specified in toggle() method', async () => {
|
|
1117
|
-
const App = {
|
|
1118
|
-
render(h) {
|
|
1119
|
-
return h('div', [
|
|
1120
|
-
h('button', { class: 'trigger', attrs: { id: 'trigger', type: 'button' } }, 'trigger'),
|
|
1121
|
-
h(
|
|
1122
|
-
'button',
|
|
1123
|
-
{ class: 'return-to', attrs: { id: 'return-to', type: 'button' } },
|
|
1124
|
-
'trigger'
|
|
1125
|
-
),
|
|
1126
|
-
h(BModal, { props: { static: true, id: 'test', visible: false } }, 'modal content')
|
|
1127
|
-
])
|
|
1128
|
-
}
|
|
1129
|
-
}
|
|
1130
|
-
const wrapper = mount(App, {
|
|
1131
|
-
attachTo: document.body
|
|
1132
|
-
})
|
|
1133
|
-
|
|
1134
|
-
expect(wrapper.vm).toBeDefined()
|
|
1135
|
-
|
|
1136
|
-
await waitNT(wrapper.vm)
|
|
1137
|
-
await waitRAF()
|
|
1138
|
-
await waitNT(wrapper.vm)
|
|
1139
|
-
await waitRAF()
|
|
1140
|
-
await waitNT(wrapper.vm)
|
|
1141
|
-
await waitRAF()
|
|
1142
|
-
await waitNT(wrapper.vm)
|
|
1143
|
-
await waitRAF()
|
|
1144
|
-
|
|
1145
|
-
const $button = wrapper.find('button.trigger')
|
|
1146
|
-
expect($button.exists()).toBe(true)
|
|
1147
|
-
expect($button.element.tagName).toBe('BUTTON')
|
|
1148
|
-
|
|
1149
|
-
const $button2 = wrapper.find('button.return-to')
|
|
1150
|
-
expect($button2.exists()).toBe(true)
|
|
1151
|
-
expect($button2.element.tagName).toBe('BUTTON')
|
|
1152
|
-
|
|
1153
|
-
const $modal = wrapper.find('div.modal')
|
|
1154
|
-
expect($modal.exists()).toBe(true)
|
|
1155
|
-
|
|
1156
|
-
expect($modal.element.style.display).toEqual('none')
|
|
1157
|
-
expect(document.activeElement).toBe(document.body)
|
|
1158
|
-
|
|
1159
|
-
// Set the active element to the button
|
|
1160
|
-
$button.element.focus()
|
|
1161
|
-
expect(document.activeElement).toBe($button.element)
|
|
1162
|
-
|
|
1163
|
-
// Try and open modal via `.toggle()` method
|
|
1164
|
-
wrapper.findComponent(BModal).vm.toggle('button.return-to')
|
|
1165
|
-
|
|
1166
|
-
await waitNT(wrapper.vm)
|
|
1167
|
-
await waitRAF()
|
|
1168
|
-
await waitNT(wrapper.vm)
|
|
1169
|
-
await waitRAF()
|
|
1170
|
-
await waitNT(wrapper.vm)
|
|
1171
|
-
await waitRAF()
|
|
1172
|
-
await waitNT(wrapper.vm)
|
|
1173
|
-
await waitRAF()
|
|
1174
|
-
|
|
1175
|
-
// Modal should now be open
|
|
1176
|
-
expect($modal.element.style.display).toEqual('')
|
|
1177
|
-
expect(document.activeElement).not.toBe(document.body)
|
|
1178
|
-
expect(document.activeElement).not.toBe($button.element)
|
|
1179
|
-
expect(document.activeElement).not.toBe($button2.element)
|
|
1180
|
-
expect($modal.element.contains(document.activeElement)).toBe(true)
|
|
1181
|
-
|
|
1182
|
-
// Try and close modal via `.toggle()` method
|
|
1183
|
-
wrapper.findComponent(BModal).vm.toggle()
|
|
1184
|
-
|
|
1185
|
-
await waitNT(wrapper.vm)
|
|
1186
|
-
await waitRAF()
|
|
1187
|
-
await waitNT(wrapper.vm)
|
|
1188
|
-
await waitRAF()
|
|
1189
|
-
await waitNT(wrapper.vm)
|
|
1190
|
-
await waitRAF()
|
|
1191
|
-
await waitNT(wrapper.vm)
|
|
1192
|
-
await waitRAF()
|
|
1193
|
-
|
|
1194
|
-
// Modal should now be closed
|
|
1195
|
-
expect($modal.element.style.display).toEqual('none')
|
|
1196
|
-
expect(document.activeElement).toBe($button2.element)
|
|
1197
|
-
|
|
1198
|
-
wrapper.destroy()
|
|
1199
|
-
})
|
|
1200
|
-
|
|
1201
|
-
it('if focus leaves modal it returns to modal', async () => {
|
|
1202
|
-
const App = {
|
|
1203
|
-
render(h) {
|
|
1204
|
-
return h('div', [
|
|
1205
|
-
h('button', { attrs: { id: 'button', type: 'button' } }, 'Button'),
|
|
1206
|
-
h(BModal, { props: { static: true, id: 'test', visible: true } }, 'Modal content')
|
|
1207
|
-
])
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
|
-
const wrapper = mount(App, {
|
|
1211
|
-
attachTo: document.body
|
|
1212
|
-
})
|
|
1213
|
-
|
|
1214
|
-
expect(wrapper.vm).toBeDefined()
|
|
1215
|
-
|
|
1216
|
-
await waitNT(wrapper.vm)
|
|
1217
|
-
await waitRAF()
|
|
1218
|
-
await waitNT(wrapper.vm)
|
|
1219
|
-
await waitRAF()
|
|
1220
|
-
await waitNT(wrapper.vm)
|
|
1221
|
-
await waitRAF()
|
|
1222
|
-
await waitNT(wrapper.vm)
|
|
1223
|
-
await waitRAF()
|
|
1224
|
-
|
|
1225
|
-
const $button = wrapper.find('#button')
|
|
1226
|
-
expect($button.exists()).toBe(true)
|
|
1227
|
-
expect($button.element.tagName).toBe('BUTTON')
|
|
1228
|
-
|
|
1229
|
-
const $modal = wrapper.find('div.modal')
|
|
1230
|
-
expect($modal.exists()).toBe(true)
|
|
1231
|
-
const $content = $modal.find('div.modal-content')
|
|
1232
|
-
expect($content.exists()).toBe(true)
|
|
1233
|
-
|
|
1234
|
-
expect($modal.element.style.display).toEqual('')
|
|
1235
|
-
expect(document.activeElement).not.toBe(document.body)
|
|
1236
|
-
expect(document.activeElement).toBe($content.element)
|
|
1237
|
-
|
|
1238
|
-
// Try and focus the external button
|
|
1239
|
-
$button.element.focus()
|
|
1240
|
-
await $button.trigger('focusin')
|
|
1241
|
-
expect(document.activeElement).not.toBe($button.element)
|
|
1242
|
-
expect(document.activeElement).toBe($content.element)
|
|
1243
|
-
|
|
1244
|
-
// Emulate TAB by focusing the `bottomTrap` span element
|
|
1245
|
-
// Should focus first button in modal (in the header)
|
|
1246
|
-
const $bottomTrap = createWrapper(wrapper.findComponent(BModal).vm.$refs['bottom-trap'])
|
|
1247
|
-
expect($bottomTrap.exists()).toBe(true)
|
|
1248
|
-
expect($bottomTrap.element.tagName).toBe('SPAN')
|
|
1249
|
-
// Find the close (x) button (it is the only one with the `.close` class)
|
|
1250
|
-
const $closeButton = $modal.find('button.close')
|
|
1251
|
-
expect($closeButton.exists()).toBe(true)
|
|
1252
|
-
expect($closeButton.element.tagName).toBe('BUTTON')
|
|
1253
|
-
// Focus the tab trap
|
|
1254
|
-
$bottomTrap.element.focus()
|
|
1255
|
-
await $bottomTrap.trigger('focusin')
|
|
1256
|
-
expect(document.activeElement).not.toBe($bottomTrap.element)
|
|
1257
|
-
expect(document.activeElement).not.toBe($content.element)
|
|
1258
|
-
// The close (x) button (first tabable in modal) should be focused
|
|
1259
|
-
expect(document.activeElement).toBe($closeButton.element)
|
|
1260
|
-
|
|
1261
|
-
// Emulate CTRL-TAB by focusing the `topTrap` div element
|
|
1262
|
-
// Should focus last button in modal (in the footer)
|
|
1263
|
-
const $topTrap = createWrapper(wrapper.findComponent(BModal).vm.$refs['top-trap'])
|
|
1264
|
-
expect($topTrap.exists()).toBe(true)
|
|
1265
|
-
expect($topTrap.element.tagName).toBe('SPAN')
|
|
1266
|
-
// Find the OK button (it is the only one with `.btn-primary` class)
|
|
1267
|
-
const $okButton = $modal.find('button.btn.btn-primary')
|
|
1268
|
-
expect($okButton.exists()).toBe(true)
|
|
1269
|
-
expect($okButton.element.tagName).toBe('BUTTON')
|
|
1270
|
-
// Focus the tab trap
|
|
1271
|
-
$topTrap.element.focus()
|
|
1272
|
-
await $topTrap.trigger('focusin')
|
|
1273
|
-
expect(document.activeElement).not.toBe($topTrap.element)
|
|
1274
|
-
expect(document.activeElement).not.toBe($bottomTrap.element)
|
|
1275
|
-
expect(document.activeElement).not.toBe($content.element)
|
|
1276
|
-
// The OK button (last tabbable in modal) should be focused
|
|
1277
|
-
expect(document.activeElement).toBe($okButton.element)
|
|
1278
|
-
|
|
1279
|
-
wrapper.destroy()
|
|
1280
|
-
})
|
|
1281
|
-
|
|
1282
|
-
it('it allows focus for elements when "no-enforce-focus" enabled', async () => {
|
|
1283
|
-
const App = {
|
|
1284
|
-
render(h) {
|
|
1285
|
-
return h('div', [
|
|
1286
|
-
h('button', { attrs: { id: 'button1', type: 'button' } }, 'Button 1'),
|
|
1287
|
-
h('button', { attrs: { id: 'button2', type: 'button' } }, 'Button 2'),
|
|
1288
|
-
h(
|
|
1289
|
-
BModal,
|
|
1290
|
-
{
|
|
1291
|
-
props: {
|
|
1292
|
-
static: true,
|
|
1293
|
-
id: 'test',
|
|
1294
|
-
visible: true,
|
|
1295
|
-
noEnforceFocus: true
|
|
1296
|
-
}
|
|
1297
|
-
},
|
|
1298
|
-
'Modal content'
|
|
1299
|
-
)
|
|
1300
|
-
])
|
|
1301
|
-
}
|
|
1302
|
-
}
|
|
1303
|
-
const wrapper = mount(App, {
|
|
1304
|
-
attachTo: document.body
|
|
1305
|
-
})
|
|
1306
|
-
|
|
1307
|
-
expect(wrapper.vm).toBeDefined()
|
|
1308
|
-
|
|
1309
|
-
await waitNT(wrapper.vm)
|
|
1310
|
-
await waitRAF()
|
|
1311
|
-
await waitNT(wrapper.vm)
|
|
1312
|
-
await waitRAF()
|
|
1313
|
-
await waitNT(wrapper.vm)
|
|
1314
|
-
await waitRAF()
|
|
1315
|
-
await waitNT(wrapper.vm)
|
|
1316
|
-
await waitRAF()
|
|
1317
|
-
|
|
1318
|
-
const $button1 = wrapper.find('#button1')
|
|
1319
|
-
expect($button1.exists()).toBe(true)
|
|
1320
|
-
expect($button1.element.tagName).toBe('BUTTON')
|
|
1321
|
-
|
|
1322
|
-
const $button2 = wrapper.find('#button2')
|
|
1323
|
-
expect($button2.exists()).toBe(true)
|
|
1324
|
-
expect($button2.element.tagName).toBe('BUTTON')
|
|
1325
|
-
|
|
1326
|
-
const $modal = wrapper.find('div.modal')
|
|
1327
|
-
expect($modal.exists()).toBe(true)
|
|
1328
|
-
const $content = $modal.find('div.modal-content')
|
|
1329
|
-
expect($content.exists()).toBe(true)
|
|
1330
|
-
|
|
1331
|
-
expect($modal.element.style.display).toEqual('')
|
|
1332
|
-
expect(document.activeElement).not.toBe(document.body)
|
|
1333
|
-
expect(document.activeElement).toBe($content.element)
|
|
1334
|
-
|
|
1335
|
-
// Try to focus button1
|
|
1336
|
-
$button1.element.focus()
|
|
1337
|
-
await $button1.trigger('focusin')
|
|
1338
|
-
expect(document.activeElement).toBe($button1.element)
|
|
1339
|
-
expect(document.activeElement).not.toBe($content.element)
|
|
1340
|
-
|
|
1341
|
-
// Try to focus button2
|
|
1342
|
-
$button2.element.focus()
|
|
1343
|
-
await $button2.trigger('focusin')
|
|
1344
|
-
expect(document.activeElement).toBe($button2.element)
|
|
1345
|
-
expect(document.activeElement).not.toBe($content.element)
|
|
1346
|
-
|
|
1347
|
-
wrapper.destroy()
|
|
1348
|
-
})
|
|
1349
|
-
|
|
1350
|
-
it('it allows focus for elements in "ignore-enforce-focus-selector" prop', async () => {
|
|
1351
|
-
const App = {
|
|
1352
|
-
render(h) {
|
|
1353
|
-
return h('div', [
|
|
1354
|
-
h('button', { attrs: { id: 'button1', type: 'button' } }, 'Button 1'),
|
|
1355
|
-
h('button', { attrs: { id: 'button2', type: 'button' } }, 'Button 2'),
|
|
1356
|
-
h(
|
|
1357
|
-
BModal,
|
|
1358
|
-
{
|
|
1359
|
-
props: {
|
|
1360
|
-
static: true,
|
|
1361
|
-
id: 'test',
|
|
1362
|
-
visible: true,
|
|
1363
|
-
ignoreEnforceFocusSelector: '#button1'
|
|
1364
|
-
}
|
|
1365
|
-
},
|
|
1366
|
-
'Modal content'
|
|
1367
|
-
)
|
|
1368
|
-
])
|
|
1369
|
-
}
|
|
1370
|
-
}
|
|
1371
|
-
const wrapper = mount(App, {
|
|
1372
|
-
attachTo: document.body
|
|
1373
|
-
})
|
|
1374
|
-
|
|
1375
|
-
expect(wrapper.vm).toBeDefined()
|
|
1376
|
-
|
|
1377
|
-
await waitNT(wrapper.vm)
|
|
1378
|
-
await waitRAF()
|
|
1379
|
-
await waitNT(wrapper.vm)
|
|
1380
|
-
await waitRAF()
|
|
1381
|
-
await waitNT(wrapper.vm)
|
|
1382
|
-
await waitRAF()
|
|
1383
|
-
await waitNT(wrapper.vm)
|
|
1384
|
-
await waitRAF()
|
|
1385
|
-
|
|
1386
|
-
const $button1 = wrapper.find('#button1')
|
|
1387
|
-
expect($button1.exists()).toBe(true)
|
|
1388
|
-
expect($button1.element.tagName).toBe('BUTTON')
|
|
1389
|
-
|
|
1390
|
-
const $button2 = wrapper.find('#button2')
|
|
1391
|
-
expect($button2.exists()).toBe(true)
|
|
1392
|
-
expect($button2.element.tagName).toBe('BUTTON')
|
|
1393
|
-
|
|
1394
|
-
const $modal = wrapper.find('div.modal')
|
|
1395
|
-
expect($modal.exists()).toBe(true)
|
|
1396
|
-
const $content = $modal.find('div.modal-content')
|
|
1397
|
-
expect($content.exists()).toBe(true)
|
|
1398
|
-
|
|
1399
|
-
expect($modal.element.style.display).toEqual('')
|
|
1400
|
-
expect(document.activeElement).not.toBe(document.body)
|
|
1401
|
-
expect(document.activeElement).toBe($content.element)
|
|
1402
|
-
|
|
1403
|
-
// Try to focus button1
|
|
1404
|
-
$button1.element.focus()
|
|
1405
|
-
await $button1.trigger('focusin')
|
|
1406
|
-
expect(document.activeElement).toBe($button1.element)
|
|
1407
|
-
expect(document.activeElement).not.toBe($content.element)
|
|
1408
|
-
|
|
1409
|
-
// Try to focus button2
|
|
1410
|
-
$button2.element.focus()
|
|
1411
|
-
await $button2.trigger('focusin')
|
|
1412
|
-
expect(document.activeElement).not.toBe($button2.element)
|
|
1413
|
-
expect(document.activeElement).toBe($content.element)
|
|
1414
|
-
|
|
1415
|
-
wrapper.destroy()
|
|
1416
|
-
})
|
|
1417
|
-
})
|
|
1418
|
-
})
|