✅ test: added test file
This commit is contained in:
parent
80a0cb656a
commit
2938e3bd2b
45
test/VFileUpload.spec.ts
Normal file
45
test/VFileUpload.spec.ts
Normal file
|
@ -0,0 +1,45 @@
|
|||
import { mount } from '@vue/test-utils';
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
import VFileUpload from '../src/components/file/VFileUpload.vue'
|
||||
|
||||
describe('VFileUpload emits', () => {
|
||||
it('doit émettre les événements personnalisés', async () => {
|
||||
// Création des mocks
|
||||
const onSelect = vi.fn();
|
||||
const onUpload = vi.fn();
|
||||
const onError = vi.fn();
|
||||
const onRemove = vi.fn();
|
||||
const onClear = vi.fn();
|
||||
|
||||
const wrapper = mount(VFileUpload, {
|
||||
props: {
|
||||
advanced: true,
|
||||
onSelect,
|
||||
onUpload,
|
||||
onError,
|
||||
onRemove,
|
||||
onClear
|
||||
}
|
||||
});
|
||||
|
||||
// Simule une sélection de fichier
|
||||
await wrapper.vm.$emit('select', { files: [{ name: 'test.png' }] });
|
||||
expect(onSelect).toHaveBeenCalledWith({ files: [{ name: 'test.png' }] });
|
||||
|
||||
// Simule une erreur
|
||||
await wrapper.vm.$emit('error', { message: 'Erreur test' });
|
||||
expect(onError).toHaveBeenCalledWith({ message: 'Erreur test' });
|
||||
|
||||
// Simule un upload
|
||||
await wrapper.vm.$emit('upload', { files: ['fichier1'] });
|
||||
expect(onUpload).toHaveBeenCalledWith({ files: ['fichier1'] });
|
||||
|
||||
// Simule une suppression
|
||||
await wrapper.vm.$emit('remove', { file: 'test.png' });
|
||||
expect(onRemove).toHaveBeenCalledWith({ file: 'test.png' });
|
||||
|
||||
// Simule un clear
|
||||
await wrapper.vm.$emit('clear');
|
||||
expect(onClear).toHaveBeenCalled();
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user