feat: add unit tests for tenant, guarantor, lease card, dashboard, session, theme, and workspace services

This commit is contained in:
nessar committed 2026-08-17 14:18:15 +02:00
1 parent 74a77f2d2b
commit 181410e28f
8 files changed
+514 -2

No files matched your search

@@ -0,0 +1,38 @@
import { TestBed } from '@angular/core/testing';
import { vi } from 'vitest';
import { GuarantorForm } from './guarantor-form';
describe('GuarantorForm', () => {
it('marks an invalid form as touched without submitting it', () => {
const fixture = TestBed.createComponent(GuarantorForm);
const markAllAsTouched = vi.fn();
const submitted = vi.fn();
fixture.componentInstance.submitted.subscribe(submitted);
fixture.componentInstance.save({ invalid: true, control: { markAllAsTouched } } as never);
expect(markAllAsTouched).toHaveBeenCalled();
expect(submitted).not.toHaveBeenCalled();
});
it('emits trimmed data and resets the form after saving', () => {
const fixture = TestBed.createComponent(GuarantorForm);
const component = fixture.componentInstance;
const submitted = vi.fn();
const resetForm = vi.fn();
component.submitted.subscribe(submitted);
component.firstName.set(' Alex ');
component.lastName.set(' Durand ');
component.email.set(' alex@example.com ');
component.phone.set(' 0600000000 ');
component.address.set(' 1 rue de Paris ');
component.save({ invalid: false, resetForm } as never);
expect(submitted).toHaveBeenCalledWith({
firstName: 'Alex', lastName: 'Durand', email: 'alex@example.com', phone: '0600000000', address: '1 rue de Paris',
});
expect(component.firstName()).toBe('');
expect(resetForm).toHaveBeenCalled();
});
});