feat: add unit tests for tenant, guarantor, lease card, dashboard, session, theme, and workspace services
This commit is contained in:
1 parent
74a77f2d2b
commit
181410e28f
8 files changed
+514
-2
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { vi } from 'vitest';
|
||||
import { TenantForm } from './tenant-form';
|
||||
|
||||
describe('TenantForm', () => {
|
||||
@@ -15,4 +16,21 @@ describe('TenantForm', () => {
|
||||
|
||||
expect(firstName).toBe('Camille');
|
||||
});
|
||||
|
||||
it('loads an existing tenant and leaves invalid data untouched', () => {
|
||||
const fixture = TestBed.createComponent(TenantForm);
|
||||
fixture.componentRef.setInput('tenant', {
|
||||
id: 'tenant-1', firstName: 'Camille', lastName: 'Martin', email: 'camille@example.com', phone: '0600000000', address: '1 rue de Paris',
|
||||
});
|
||||
fixture.detectChanges();
|
||||
const markAllAsTouched = vi.fn();
|
||||
const submitted = vi.fn();
|
||||
fixture.componentInstance.submitted.subscribe(submitted);
|
||||
|
||||
fixture.componentInstance.save({ invalid: true, control: { markAllAsTouched } } as never);
|
||||
|
||||
expect(fixture.componentInstance.firstName()).toBe('Camille');
|
||||
expect(markAllAsTouched).toHaveBeenCalled();
|
||||
expect(submitted).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user