Skip to content

Commit 1aad913

Browse files
authored
Update form-spinbutton.spec.js
1 parent efba569 commit 1aad913

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

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

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('form-spinbutton', () => {
1818
// We always have LTR to ensire the flex order stays ltr
1919
expect(wrapper.attributes('dir')).toEqual('ltr')
2020

21-
// Should ahve 3 child elements (btn, output, btn)
21+
// Should have 3 child elements (btn, output, btn)
2222
expect(wrapper.findAll('.b-form-spinbutton > *').length).toBe(3)
2323

2424
const $decrement = wrapper.find('[aria-label="Decrement"]')
@@ -51,6 +51,55 @@ describe('form-spinbutton', () => {
5151
wrapper.destroy()
5252
})
5353

54+
it('has expected structure when value set', async () => {
55+
const wrapper = mount(BFormSpinbutton, {
56+
propsData: {
57+
min: 0,
58+
max: 10,
59+
value: 5
60+
}
61+
})
62+
expect(wrapper.isVueInstance()).toBe(true)
63+
await waitNT(wrapper.vm)
64+
await waitRAF()
65+
66+
expect(wrapper.classes()).toContain('b-form-spinbutton')
67+
expect(wrapper.classes()).toContain('form-control')
68+
expect(wrapper.classes()).toContain('d-flex')
69+
expect(wrapper.classes()).toContain('align-items-stretch')
70+
expect(wrapper.attributes('role')).toEqual('group')
71+
expect(wrapper.attributes('tabindex')).toEqual('-1')
72+
// We always have LTR to ensire the flex order stays ltr
73+
expect(wrapper.attributes('dir')).toEqual('ltr')
74+
75+
// Should have 3 child elements (btn, output, btn)
76+
expect(wrapper.findAll('.b-form-spinbutton > *').length).toBe(3)
77+
78+
const $decrement = wrapper.find('[aria-label="Decrement"]')
79+
expect($decrement.exists()).toBe(true)
80+
expect($decrement.is('button')).toBe(true)
81+
expect($decrement.attributes('tabindex')).toEqual('-1')
82+
expect($decrement.attributes('aria-keyshortcuts')).toEqual('ArrowDown')
83+
84+
const $increment = wrapper.find('[aria-label="Increment"]')
85+
expect($increment.exists()).toBe(true)
86+
expect($increment.is('button')).toBe(true)
87+
expect($increment.attributes('tabindex')).toEqual('-1')
88+
expect($decrement.attributes('aria-keyshortcuts')).toEqual('ArrowUp')
89+
90+
const $output = wrapper.find('output')
91+
expect($output.exists()).toBe(true)
92+
expect($output.attributes('role')).toEqual('spinbutton')
93+
expect($output.attributes('tabindex')).toEqual('0')
94+
expect($output.attributes('aria-live')).toEqual('off')
95+
expect($output.attributes('aria-valuemin')).toEqual('0')
96+
expect($output.attributes('aria-valuemax')).toEqual('10')
97+
expect($output.attributes('aria-valuenow')).toEqual('5')
98+
expect($output.attributes('aria-valuetext')).toEqual('5')
99+
100+
wrapper.destroy()
101+
})
102+
54103
it('renders hidden input when name set', async () => {
55104
const wrapper = mount(BFormSpinbutton, {
56105
propsData: {

0 commit comments

Comments
 (0)