mise en place des tests et test de workflows

This commit is contained in:
styve Lioumba
2025-08-25 20:55:34 +02:00
parent 4fb600b0cb
commit 4dd84c129c
9 changed files with 72 additions and 114 deletions

View File

@@ -21,6 +21,7 @@ describe('LoginComponent', () => {
mockToastrService = {
warning: jest.fn(),
success: jest.fn(),
info: jest.fn(),
error: jest.fn()
};
@@ -41,6 +42,11 @@ describe('LoginComponent', () => {
fixture.detectChanges();
});
afterEach(() => {
// si le composant instancie subscriptions/timers
fixture.destroy();
});
it('should create', () => {
expect(component).toBeTruthy();
});
@@ -79,9 +85,9 @@ describe('LoginComponent', () => {
await component.login({email: 'fail@test.com', password: 'fail'});
expect(mockToastrService.warning).toHaveBeenCalledWith(
expect(mockToastrService.info).toHaveBeenCalledWith(
'Vous devez vérifier votre adresse e-mail avant de vous connecter.',
'Erreur de connexion',
'Information de connexion',
{
closeButton: true,
progressAnimation: 'decreasing',

View File

@@ -1,2 +1,9 @@
import { setupZoneTestEnv } from "jest-preset-angular/setup-env/zone";
import * as fetch from 'node-fetch';
(global as any).fetch = fetch;
(global as any).Headers = fetch.Headers;
(global as any).Request = fetch.Request;
(global as any).Response = fetch.Response;
setupZoneTestEnv();