From 7e7070ad2ff8118f9e2f50015990c8256a82ee24 Mon Sep 17 00:00:00 2001 From: Paul Valerie GOMA Date: Mon, 21 Jul 2025 16:26:07 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20test:=20added=20accordion=20compone?= =?UTF-8?q?nt=20test=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/VAccordion.spec.ts | 57 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 test/VAccordion.spec.ts diff --git a/test/VAccordion.spec.ts b/test/VAccordion.spec.ts new file mode 100644 index 0000000..aa6c1dc --- /dev/null +++ b/test/VAccordion.spec.ts @@ -0,0 +1,57 @@ +import { describe, test, expect } from 'vitest' +import { mount } from '@vue/test-utils' +import VAccordion from '../src/components/accordion/VAccordion.vue' +import VAccordionChild from '../src/components/accordion/VAccordionChild.vue' + +describe('VAccordion', () => { + const factory = () => + mount(VAccordion, { + props: { + value: '0', + }, + slots: { + default: ` + + + + + + + + + + + + + `, + }, + global: { + components: { + VAccordionChild, + }, + }, + }) + + test('renders three accordion panels', () => { + const wrapper = factory() + const panels = wrapper.findAll('.p-accordionpanel') + expect(panels).toHaveLength(3) + }) + + test('activates the first panel by default', () => { + const wrapper = factory() + const firstPanel = wrapper.findAll('.p-accordionpanel')[0] + expect(firstPanel.classes()).toContain('p-accordionpanel-active') + expect(firstPanel.attributes('data-p-active')).toBe('true') + }) + + test('disables the second panel', () => { + const wrapper = factory() + const secondPanel = wrapper.findAll('.p-accordionpanel')[1] + expect(secondPanel.classes()).toContain('p-disabled') + expect(secondPanel.attributes('data-p-disabled')).toBe('true') + expect(secondPanel.find('button').attributes('disabled')).toBeDefined() + }) +})