import { Decimal } from 'decimal.js'; import { describe, expect, it } from 'vitest'; import { Intervention } from '../../src/domain/intervention.js'; const make = (overrides: Partial[0]> = {}) => new Intervention({ id: 1, tacheId: 10, personneId: 5, heures: new Decimal(4), date: new Date('2026-05-01'), ...overrides, }); describe('Intervention', () => { it('cree une intervention valide', () => { const i = make(); expect(i.statut).toBe('realise'); expect(i.isActive()).toBe(true); }); it('throw si heures <= 0', () => { expect(() => make({ heures: new Decimal(0) })).toThrow(); expect(() => make({ heures: new Decimal(-1) })).toThrow(); }); it('annuler depuis realise', () => { const i = make(); i.annuler('erreur saisie'); expect(i.statut).toBe('annule'); expect(i.isActive()).toBe(false); }); it('throw si annule deja annulee', () => { const i = make({ statut: 'annule' }); expect(() => i.annuler('test')).toThrow(); }); it('isActive false sur annule', () => { expect(make({ statut: 'annule' }).isActive()).toBe(false); expect(make({ statut: 'planifie' }).isActive()).toBe(true); }); });