From 020ac1bc8dbfce53cb3685274c452e64636a12f8 Mon Sep 17 00:00:00 2001 From: Paul Valerie GOMA Date: Mon, 21 Jul 2025 12:54:01 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20test:=20added=20a=20test=20that=20p?= =?UTF-8?q?revents=20clicking=20when=20the=20link=20is=20disabled?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/VLink.spec.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/test/VLink.spec.ts b/test/VLink.spec.ts index fc91dce..838ced8 100644 --- a/test/VLink.spec.ts +++ b/test/VLink.spec.ts @@ -1,6 +1,6 @@ import { mount } from '@vue/test-utils' import VLink from '../src/components/button/VLink.vue' -import {test, expect, describe} from 'vitest' +import {test, expect, describe, vi} from 'vitest' describe('VLink', () => { test('renders the label correctly', () => { @@ -32,5 +32,14 @@ describe('VLink', () => { expect(button.attributes('aria-disabled')).toBe('true'); }); - + test('prevents click when disabled', async () => { + const clickHandler = vi.fn(); + const wrapper = mount(VLink, { + props: {label: 'Disabled', disabled: true, onClick: clickHandler} + }) + + await wrapper.trigger('click') + expect(clickHandler).not.toHaveBeenCalled(); + }); + })