61 lines
1.9 KiB
TypeScript
61 lines
1.9 KiB
TypeScript
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
|
|
import { MyProfileComponent } from './my-profile.component';
|
|
import { provideRouter } from '@angular/router';
|
|
import { ProfileRepository } from '@app/domain/profiles/profile.repository';
|
|
import { PROFILE_REPOSITORY_TOKEN } from '@app/infrastructure/profiles/profile-repository.token';
|
|
import { of } from 'rxjs';
|
|
import { Profile } from '@app/domain/profiles/profile.model';
|
|
import { ToastrService } from 'ngx-toastr';
|
|
import { USER_REPOSITORY_TOKEN } from '@app/infrastructure/users/user-repository.token';
|
|
import { UserRepository } from '@app/domain/users/user.repository';
|
|
|
|
describe('MyProfileComponent', () => {
|
|
let component: MyProfileComponent;
|
|
let fixture: ComponentFixture<MyProfileComponent>;
|
|
|
|
let mockProfileRepo: ProfileRepository;
|
|
let mockUserRepo: UserRepository;
|
|
let mockToastrService: Partial<ToastrService>;
|
|
|
|
beforeEach(async () => {
|
|
mockProfileRepo = {
|
|
create: jest.fn(),
|
|
list: jest.fn(),
|
|
update: jest.fn(),
|
|
getByUserId: jest.fn().mockReturnValue(of({} as Profile)),
|
|
};
|
|
|
|
mockUserRepo = {
|
|
update: jest.fn(),
|
|
getUserById: jest.fn(),
|
|
};
|
|
|
|
mockToastrService = {
|
|
warning: jest.fn(),
|
|
success: jest.fn(),
|
|
info: jest.fn(),
|
|
error: jest.fn(),
|
|
};
|
|
await TestBed.configureTestingModule({
|
|
imports: [MyProfileComponent],
|
|
providers: [
|
|
provideRouter([]),
|
|
{ provide: PROFILE_REPOSITORY_TOKEN, useValue: mockProfileRepo },
|
|
{ provide: USER_REPOSITORY_TOKEN, useValue: mockUserRepo },
|
|
{ provide: ToastrService, useValue: mockToastrService },
|
|
],
|
|
}).compileComponents();
|
|
|
|
fixture = TestBed.createComponent(MyProfileComponent);
|
|
component = fixture.componentInstance;
|
|
fixture.detectChanges();
|
|
|
|
await fixture.whenStable();
|
|
});
|
|
|
|
it('should create', () => {
|
|
expect(component).toBeTruthy();
|
|
});
|
|
});
|