8000 Update form-group.spec.js · bootstrap-vue/bootstrap-vue@dbfcf19 · GitHub
[go: up one dir, main page]

Skip to content

Commit dbfcf19

Browse files
committed
Update form-group.spec.js
1 parent fd865a8 commit dbfcf19

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/components/form-group/form-group.spec.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,43 @@ describe('form-group', () => {
253253
wrapper.destroy()
254254
})
255255

256+
it('horizontal layout without label content has expected structure', async () => {
257+
const wrapper = mount(BFormGroup, {
258+
propsData: {
259+
labelCols: 1
260+
},
261+
slots: {
262+
default: '<input id="input-id" type="text">'
263+
}
264+
})
265+
266+
expect(wrapper.vm).toBeDefined()
267+
268+
// Auto ID is created after mounted
269+
await waitNT(wrapper.vm)
270+
271+
expect(wrapper.element.tagName).toBe('FIELDSET')
272+
expect(wrapper.element.tagName).not.toBe('DIV')
273+
expect(wrapper.find('legend').exists()).toBe(true)
274+
expect(wrapper.find('fieldset > div > legend').exists()).toBe(true)
275+
expect(wrapper.classes()).toContain('form-group')
276+
expect(wrapper.classes().length).toBe(1)
277+
expect(wrapper.attributes('role')).not.toBeDefined()
278+
expect(wrapper.attributes('aria-labelledby')).not.toBeDefined()
279+
expect(wrapper.find('legend').classes()).toContain('col-form-label')
280+
expect(wrapper.find('legend').classes()).toContain('col-1')
281+
expect(wrapper.find('legend').classes()).toContain('bv-no-focus-ring')
282+
expect(wrapper.find('legend').text()).toEqual('')
283+
expect(wrapper.find('fieldset > div > div').exists()).toBe(true)
284+
expect(wrapper.find('fieldset > div > div').classes()).toContain('col')
285+
expect(wrapper.find('fieldset > div > div').classes()).toContain('bv-no-focus-ring')
286+
expect(wrapper.find('fieldset > div > div').classes().length).toBe(2)
287+
expect(wrapper.find('fieldset > div > div').attributes('role')).toEqual('group')
288+
expect(wrapper.find('fieldset > div > div').attributes('tabindex')).toEqual('-1')
289+
290+
wrapper.destroy()
291+
})
292+
256293
it('validation and help text works', async () => {
257294
const wrapper = mount(BFormGroup, {
258295
propsData: {

0 commit comments

Comments
 (0)
0