From 5f8a7ae4c2e49248afe9abf53df564e240a5082a Mon Sep 17 00:00:00 2001 From: Paul Valerie GOMA Date: Thu, 31 Jul 2025 11:09:47 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20test:=20added=20test=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/VuseConfirmModal.spec.ts | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 test/VuseConfirmModal.spec.ts diff --git a/test/VuseConfirmModal.spec.ts b/test/VuseConfirmModal.spec.ts new file mode 100644 index 0000000..7cb0661 --- /dev/null +++ b/test/VuseConfirmModal.spec.ts @@ -0,0 +1,34 @@ +// tests/useConfirmModal.spec.ts +import { describe, it, expect, vi } from 'vitest' + +// ✅ Mock AVANT import de useConfirmModal +const requireSpy = vi.fn() +vi.mock('primevue', () => ({ + useConfirm: () => ({ + require: requireSpy + }) +})) + +import { useConfirmModal } from '../src/components/composable/useConfirmModal' + +describe('useConfirmModal', () => { + it('should call confirm.require with the given options', () => { + const { showConfirmModal } = useConfirmModal() + + const options = { + header: 'Confirm Header', + message: 'Are you sure?', + accept: vi.fn(), + reject: vi.fn(), + } + + showConfirmModal(options) + + expect(requireSpy).toHaveBeenCalledWith(expect.objectContaining({ + header: 'Confirm Header', + message: 'Are you sure?', + accept: options.accept, + reject: options.reject, + })) + }) +})