From 714d79781fdfe97c9ff63a05f49958efd98f2815 Mon Sep 17 00:00:00 2001 From: Paul Valerie GOMA Date: Sat, 19 Jul 2025 16:53:31 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20test:=20Added=20variant=20button=20?= =?UTF-8?q?test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/VButton.spec.ts | 76 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/test/VButton.spec.ts b/test/VButton.spec.ts index 2f6208c..d0cc48f 100644 --- a/test/VButton.spec.ts +++ b/test/VButton.spec.ts @@ -133,4 +133,80 @@ describe('VButton', () => { expect(button.classes()).not.toContain('p-button-sm') expect(button.classes().some(c => c.includes('text-body-MD'))).toBe(true) }) + + test('primary button', () => { + const wrapper = mount(VButton, { + props: { + title: 'button', + label: 'label', + } + }) + const button = wrapper.find('button') + expect(button.classes()).not.toContain('p-button-secondary') + expect(button.classes()).not.toContain('p-button-outlined') + expect(button.classes()).not.toContain('p-button-text') + expect(button.classes()).not.toContain('p-button-danger') + }) + + test('secondary button', () => { + const wrapper = mount(VButton, { + props: { + title: 'button', + label: 'label', + secondary: true, + } + }) + const button = wrapper.find('button') + expect(button.classes()).toContain('p-button-secondary') + expect(button.classes()).toContain('p-button-outlined') + expect(button.classes()).not.toContain('p-button-text') + expect(button.classes()).not.toContain('p-button-danger') + expect(button.attributes('data-p-severity')).toBe('secondary') + }) + + test('tertiary button', () => { + const wrapper = mount(VButton, { + props: { + title: 'button', + label: 'label', + tertiary: true + } + }) + const button = wrapper.find('button') + expect(button.classes()).not.toContain('p-button-secondary') + expect(button.classes()).toContain('p-button-outlined') + expect(button.classes()).not.toContain('p-button-text') + expect(button.classes()).not.toContain('p-button-danger') + }) + + test('no outlined button', () => { + const wrapper = mount(VButton, { + props: { + title: 'button', + label: 'label', + noOutline: true, + } + }) + const button = wrapper.find('button') + expect(button.classes()).not.toContain('p-button-secondary') + expect(button.classes()).not.toContain('p-button-outlined') + expect(button.classes()).toContain('p-button-text') + expect(button.classes()).not.toContain('p-button-danger') + }) + + test('danger variant button', () => { + const wrapper = mount(VButton, { + props: { + title: 'button', + label: 'label', + danger: true, + } + }) + const button = wrapper.find('button') + expect(button.classes()).not.toContain('p-button-secondary') + expect(button.classes()).not.toContain('p-button-outlined') + expect(button.classes()).not.toContain('p-button-text') + expect(button.classes()).toContain('p-button-danger') + expect(button.attributes('data-p-severity')).toBe('danger') + }) })