Files
Bonsai-webapp/src/app/projects/projects.spec.ts
T
2026-05-23 20:18:18 +02:00

51 lines
1.4 KiB
TypeScript

import { ComponentFixture, TestBed } from '@angular/core/testing';
import { Projects } from './projects';
describe('Projects', () => {
let component: Projects;
let fixture: ComponentFixture<Projects>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [Projects],
}).compileComponents();
fixture = TestBed.createComponent(Projects);
component = fixture.componentInstance;
await fixture.whenStable();
});
it('should create', () => {
expect(component).toBeTruthy();
});
it('should have 3 default projects', () => {
expect((component as any).projects().length).toBe(3);
});
it('createProject adds a new project', () => {
(component as any).createProject();
expect((component as any).projects().length).toBe(4);
});
it('createProject increments the id each time', () => {
(component as any).createProject();
(component as any).createProject();
const projects = (component as any).projects();
expect(projects[3].id).toBe(4);
expect(projects[4].id).toBe(5);
});
it('new project starts with Nouveau status', () => {
(component as any).createProject();
const newProject = (component as any).projects()[3];
expect(newProject.status).toBe('Nouveau');
});
it('new project starts with 0 progress', () => {
(component as any).createProject();
const newProject = (component as any).projects()[3];
expect(newProject.progress).toBe(0);
});
});