✅ test: Added disabled props test
This commit is contained in:
parent
e8f1d33441
commit
4b3804ca05
|
@ -1,6 +1,6 @@
|
||||||
import { mount } from '@vue/test-utils'
|
import { mount } from '@vue/test-utils'
|
||||||
import VButton from '@/components/button/VButton.vue'
|
import VButton from '@/components/button/VButton.vue'
|
||||||
import {test, expect, describe} from 'vitest'
|
import {test, expect, describe, vi} from 'vitest'
|
||||||
|
|
||||||
describe('VButton', () => {
|
describe('VButton', () => {
|
||||||
test('Displays button label', () => {
|
test('Displays button label', () => {
|
||||||
|
@ -72,4 +72,24 @@ describe('VButton', () => {
|
||||||
expect(iconRight.exists()).toBe(true)
|
expect(iconRight.exists()).toBe(true)
|
||||||
expect(iconRight.classes()).not.toContain('p-button-icon-left')
|
expect(iconRight.classes()).not.toContain('p-button-icon-left')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('Disabled button', async () => {
|
||||||
|
const onClick = vi.fn()
|
||||||
|
const wrapper = mount(VButton, {
|
||||||
|
props: {
|
||||||
|
title: 'button',
|
||||||
|
label: 'label',
|
||||||
|
disabled: true,
|
||||||
|
onClick,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const button = wrapper.find('button')
|
||||||
|
await button.trigger('click')
|
||||||
|
// check disabled props is set
|
||||||
|
expect(button.attributes('disabled')).toBeDefined()
|
||||||
|
// check aria-disabled atribute is set
|
||||||
|
expect(button.attributes('aria-disabled')).toBe('true')
|
||||||
|
// check that the onClck function hasn't been called
|
||||||
|
expect(onClick).not.toHaveBeenCalled()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user