From e8f1d3344160a0a8b82781e465cdf7f65a1bc8e1 Mon Sep 17 00:00:00 2001 From: Paul Valerie GOMA Date: Sat, 19 Jul 2025 15:17:02 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20test:=20Added=20iconRight=20props?= =?UTF-8?q?=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/VButton.spec.ts | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/test/VButton.spec.ts b/test/VButton.spec.ts index c93369f..4eb65ae 100644 --- a/test/VButton.spec.ts +++ b/test/VButton.spec.ts @@ -35,4 +35,41 @@ describe('VButton', () => { // check that the aria-label attribute is correctly defined expect(button.attributes('aria-label')).toBe('label') }) + + test('Displays label and button icon when both are set', () => { + const wrapper = mount(VButton, { + props: { + title: 'button', + label: 'label', + icon: 'ri-settings-4-line' + } + }) + const button = wrapper.find('button') + // check the rendering contains button label value + expect(button.text()).toBe('label') + // Check the icon is present + const icon = button.find('.p-button-icon') + expect(icon.exists()).toBe(true) + expect(icon.classes()).toContain('ri-settings-4-line') + // check if the button icon is shown on left by default + expect(icon.classes()).toContain('p-button-icon-left') + // check that the aria-label attribute is correctly defined + expect(button.attributes('aria-label')).toBe('label') + }) + + test('Displays button icon on right when iconRight props is set', () => { + const wrapper = mount(VButton, { + props: { + title: 'button', + label: 'label', + icon: 'ri-settings-4-line', + iconRight: true + } + }) + const button = wrapper.find('button') + // Check if button icon is on right + const iconRight = button.find('.p-button-icon-right') + expect(iconRight.exists()).toBe(true) + expect(iconRight.classes()).not.toContain('p-button-icon-left') + }) })