✅ test: added test file
This commit is contained in:
parent
184417f484
commit
5f8a7ae4c2
34
test/VuseConfirmModal.spec.ts
Normal file
34
test/VuseConfirmModal.spec.ts
Normal file
|
@ -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,
|
||||||
|
}))
|
||||||
|
})
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user