visua-vue/test/VuseConfirmModal.spec.ts
2025-07-31 11:09:47 +02:00

35 lines
856 B
TypeScript

// 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,
}))
})
})