From 4b3804ca0551b8fdd37ea8f87999c5a2d8aa05f3 Mon Sep 17 00:00:00 2001 From: Paul Valerie GOMA Date: Sat, 19 Jul 2025 15:42:14 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20test:=20Added=20disabled=20props=20?= =?UTF-8?q?test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/VButton.spec.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/test/VButton.spec.ts b/test/VButton.spec.ts index 4eb65ae..425b83c 100644 --- a/test/VButton.spec.ts +++ b/test/VButton.spec.ts @@ -1,6 +1,6 @@ import { mount } from '@vue/test-utils' import VButton from '@/components/button/VButton.vue' -import {test, expect, describe} from 'vitest' +import {test, expect, describe, vi} from 'vitest' describe('VButton', () => { test('Displays button label', () => { @@ -72,4 +72,24 @@ describe('VButton', () => { expect(iconRight.exists()).toBe(true) 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() + }) })