🔥 deleted files
This commit is contained in:
parent
65a2f9028a
commit
3c3956da68
|
@ -1,34 +0,0 @@
|
|||
import { describe, it, expect, vi } from 'vitest'
|
||||
|
||||
// 1️⃣ Mock BEFORE importing useAlert
|
||||
const addSpy = vi.fn()
|
||||
vi.mock('primevue/usetoast', () => ({
|
||||
useToast: () => ({
|
||||
add: addSpy
|
||||
})
|
||||
}))
|
||||
|
||||
// 2️⃣ Import le module après que le mock soit actif
|
||||
import { useAlert } from '../src/components/composable/useAlert'
|
||||
|
||||
describe('useAlert', () => {
|
||||
it('should call toast.add with correct options', () => {
|
||||
const { showAlert } = useAlert()
|
||||
|
||||
showAlert({
|
||||
title: 'Test title',
|
||||
description: 'Test description',
|
||||
type: 'warn',
|
||||
closeable: true,
|
||||
lifeTime: 3000,
|
||||
})
|
||||
|
||||
expect(addSpy).toHaveBeenCalledWith({
|
||||
severity: 'warn',
|
||||
summary: 'Test title',
|
||||
detail: 'Test description',
|
||||
closable: true,
|
||||
life: 3000,
|
||||
})
|
||||
})
|
||||
})
|
|
@ -1,34 +0,0 @@
|
|||
// 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