From 848d05d6dec92b086ff4fc516d63825d46b80271 Mon Sep 17 00:00:00 2001 From: Bernardo Pereira Date: Sat, 21 Sep 2024 19:48:33 -0300 Subject: [PATCH] =?UTF-8?q?test:=20criado=20novos=20testes=20unit=C3=A1rio?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/app-footer.component.mock.ts | 8 ++++ .../components/app-header.component.mock.ts | 8 ++++ .../components/invitations.component.mock.ts | 2 +- .../__mocks__/services/auth.service.mock.ts | 34 ++++++++++++++ .../dialog-confirmation.service.mock.ts | 8 ++++ .../services/invitation.service.mock.ts | 17 +++++++ .../services/project.service.mock.ts | 24 ++++++++++ .../__mocks__/services/router.service.mock.ts | 8 ++++ .../__mocks__/services/task.service.mock.ts | 20 ++++++++ ...ashboard-dialog-invitations.component.html | 2 +- ...board-dialog-invitations.component.spec.ts | 20 ++++++-- .../dashboard-dialog-invitations.component.ts | 6 ++- .../dashboard/dashboard.component.spec.ts | 40 +++++++++++++--- .../features/dashboard/dashboard.component.ts | 4 +- .../invitation/invitation.component.spec.ts | 20 ++++++-- .../features/login/login.component.spec.ts | 25 ++++++++-- .../view-project.component.spec.ts | 47 +++++++++++++++++-- .../view-project/view-project.component.ts | 10 ++-- .../register/register.component.spec.ts | 25 ++++++++-- .../invitation-page.component.spec.ts | 4 +- .../app-chip/app-chip.component.spec.ts | 12 +++-- .../app/shared/app-chip/app-chip.component.ts | 8 ++-- 22 files changed, 301 insertions(+), 51 deletions(-) create mode 100644 frontend/src/__mocks__/components/app-footer.component.mock.ts create mode 100644 frontend/src/__mocks__/components/app-header.component.mock.ts create mode 100644 frontend/src/__mocks__/services/auth.service.mock.ts create mode 100644 frontend/src/__mocks__/services/dialog-confirmation.service.mock.ts create mode 100644 frontend/src/__mocks__/services/invitation.service.mock.ts create mode 100644 frontend/src/__mocks__/services/project.service.mock.ts create mode 100644 frontend/src/__mocks__/services/router.service.mock.ts create mode 100644 frontend/src/__mocks__/services/task.service.mock.ts diff --git a/frontend/src/__mocks__/components/app-footer.component.mock.ts b/frontend/src/__mocks__/components/app-footer.component.mock.ts new file mode 100644 index 0000000..3001ced --- /dev/null +++ b/frontend/src/__mocks__/components/app-footer.component.mock.ts @@ -0,0 +1,8 @@ +import { Component } from '@angular/core'; + +@Component({ + standalone: true, + selector: 'app-footer', + template: '', +}) +export class AppFooterComponentMock {} diff --git a/frontend/src/__mocks__/components/app-header.component.mock.ts b/frontend/src/__mocks__/components/app-header.component.mock.ts new file mode 100644 index 0000000..7940b22 --- /dev/null +++ b/frontend/src/__mocks__/components/app-header.component.mock.ts @@ -0,0 +1,8 @@ +import { Component } from '@angular/core'; + +@Component({ + standalone: true, + selector: 'app-header', + template: '', +}) +export class AppHeaderComponentMock {} diff --git a/frontend/src/__mocks__/components/invitations.component.mock.ts b/frontend/src/__mocks__/components/invitations.component.mock.ts index 3ecd40c..079783f 100644 --- a/frontend/src/__mocks__/components/invitations.component.mock.ts +++ b/frontend/src/__mocks__/components/invitations.component.mock.ts @@ -1,4 +1,4 @@ import { Component } from '@angular/core'; @Component({ standalone: true, selector: 'app-invitation', template: '' }) -export class InvitationStubComponent {} +export class InvitationComponentMock {} diff --git a/frontend/src/__mocks__/services/auth.service.mock.ts b/frontend/src/__mocks__/services/auth.service.mock.ts new file mode 100644 index 0000000..00b4978 --- /dev/null +++ b/frontend/src/__mocks__/services/auth.service.mock.ts @@ -0,0 +1,34 @@ +import { Injectable } from '@angular/core'; + +import { of } from 'rxjs'; + +@Injectable({ + providedIn: 'root', +}) +export class AuthServiceMock { + logoutByUser() {} + logout() {} + alertMessageLogout() {} + setTokens() {} + setAccessToken() {} + + login() { + return of({}); + } + + register() { + return of({}); + } + + invitation() { + return of({}); + } + + refreshToken() { + return of({}); + } + + getAccessToken() { + return {}; + } +} diff --git a/frontend/src/__mocks__/services/dialog-confirmation.service.mock.ts b/frontend/src/__mocks__/services/dialog-confirmation.service.mock.ts new file mode 100644 index 0000000..827a450 --- /dev/null +++ b/frontend/src/__mocks__/services/dialog-confirmation.service.mock.ts @@ -0,0 +1,8 @@ +import { Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root', +}) +export class DialogConfirmationServiceMock { + addConfirmation() {} +} diff --git a/frontend/src/__mocks__/services/invitation.service.mock.ts b/frontend/src/__mocks__/services/invitation.service.mock.ts new file mode 100644 index 0000000..c202ab6 --- /dev/null +++ b/frontend/src/__mocks__/services/invitation.service.mock.ts @@ -0,0 +1,17 @@ +import { Injectable } from '@angular/core'; +import { of } from 'rxjs'; + +@Injectable({ + providedIn: 'root', +}) +export class InvitationServiceMock { + getInvitationForUser() { + return of({}); + } + postInvitations() { + return of({}); + } + deleteInvitation() { + return of({}); + } +} diff --git a/frontend/src/__mocks__/services/project.service.mock.ts b/frontend/src/__mocks__/services/project.service.mock.ts new file mode 100644 index 0000000..92bbca5 --- /dev/null +++ b/frontend/src/__mocks__/services/project.service.mock.ts @@ -0,0 +1,24 @@ +import { Injectable } from '@angular/core'; + +import { of } from 'rxjs'; + +@Injectable({ + providedIn: 'root', +}) +export class ProjectServiceMock { + getProject() { + return of({}); + } + getTasksForProject() { + return of({}); + } + createProjectForUser() { + return of({}); + } + editProjectForUser() { + return of({}); + } + deleteProject() { + return of({}); + } +} diff --git a/frontend/src/__mocks__/services/router.service.mock.ts b/frontend/src/__mocks__/services/router.service.mock.ts new file mode 100644 index 0000000..4408bbd --- /dev/null +++ b/frontend/src/__mocks__/services/router.service.mock.ts @@ -0,0 +1,8 @@ +import { Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root', +}) +export class RouterServiceMock { + navigate() {} +} diff --git a/frontend/src/__mocks__/services/task.service.mock.ts b/frontend/src/__mocks__/services/task.service.mock.ts new file mode 100644 index 0000000..3f177bd --- /dev/null +++ b/frontend/src/__mocks__/services/task.service.mock.ts @@ -0,0 +1,20 @@ +import { Injectable } from '@angular/core'; +import { of } from 'rxjs'; + +@Injectable({ + providedIn: 'root', +}) +export class TaskServiceMock { + getTask() { + return of({}); + } + createTask() { + return of({}); + } + editTask() { + return of({}); + } + deleteTask() { + return of({}); + } +} diff --git a/frontend/src/app/features/dashboard/components/dashboard-dialog-invites/dashboard-dialog-invitations.component.html b/frontend/src/app/features/dashboard/components/dashboard-dialog-invites/dashboard-dialog-invitations.component.html index f5e41b8..d56d329 100644 --- a/frontend/src/app/features/dashboard/components/dashboard-dialog-invites/dashboard-dialog-invitations.component.html +++ b/frontend/src/app/features/dashboard/components/dashboard-dialog-invites/dashboard-dialog-invitations.component.html @@ -22,7 +22,7 @@ formControlName="projectsId" [optionLabel]="'name'" [optionValue]="'id'" - [options]="projects()" + [options]="projects" > @if (invitations.controls.length > 1 && i > 0) { diff --git a/frontend/src/app/features/dashboard/components/dashboard-dialog-invites/dashboard-dialog-invitations.component.spec.ts b/frontend/src/app/features/dashboard/components/dashboard-dialog-invites/dashboard-dialog-invitations.component.spec.ts index ecb7c3f..aa526b7 100644 --- a/frontend/src/app/features/dashboard/components/dashboard-dialog-invites/dashboard-dialog-invitations.component.spec.ts +++ b/frontend/src/app/features/dashboard/components/dashboard-dialog-invites/dashboard-dialog-invitations.component.spec.ts @@ -1,15 +1,27 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { FormBuilder } from '@angular/forms'; +import { InvitationService } from '@core/services/invitation/invitation.service'; +import { ToastAlertService } from '@core/services/toast-alert/toast-alert.service'; +import { InvitationServiceMock } from 'src/__mocks__/services/invitation.service.mock'; +import { ToastAlertServiceMock } from 'src/__mocks__/services/toast-alert.service.mock'; import { DashboardDialogInvitationsComponent } from './dashboard-dialog-invitations.component'; describe('DashboardDialogInvitationsComponent', () => { let component: DashboardDialogInvitationsComponent; let fixture: ComponentFixture; - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [DashboardDialogInvitationsComponent], - }).compileComponents(); + beforeEach(() => { + TestBed.overrideComponent(DashboardDialogInvitationsComponent, { + set: { + imports: [DashboardDialogInvitationsComponent], + providers: [ + FormBuilder, + { provide: InvitationService, useClass: InvitationServiceMock }, + { provide: ToastAlertService, useClass: ToastAlertServiceMock }, + ], + }, + }); fixture = TestBed.createComponent(DashboardDialogInvitationsComponent); component = fixture.componentInstance; diff --git a/frontend/src/app/features/dashboard/components/dashboard-dialog-invites/dashboard-dialog-invitations.component.ts b/frontend/src/app/features/dashboard/components/dashboard-dialog-invites/dashboard-dialog-invitations.component.ts index 0be6fab..8ca5c9c 100644 --- a/frontend/src/app/features/dashboard/components/dashboard-dialog-invites/dashboard-dialog-invitations.component.ts +++ b/frontend/src/app/features/dashboard/components/dashboard-dialog-invites/dashboard-dialog-invitations.component.ts @@ -1,4 +1,4 @@ -import { Component, inject, Input, input, WritableSignal } from '@angular/core'; +import { Component, inject, Input, WritableSignal } from '@angular/core'; import { FormBuilder, FormGroup, @@ -35,9 +35,11 @@ export class DashboardDialogInvitationsComponent { private fb = inject(FormBuilder); invitationsService = inject(InvitationService); toastAlertService = inject(ToastAlertService); + @Input({ required: true, alias: 'visibleSignal' }) visibleDialogInvites!: WritableSignal; - projects = input.required(); + @Input({ required: true }) projects: ProjectForUser[] = []; + sendInvitesForm!: FormGroup; PrimeIcons = PrimeIcons; isLoadingInvites = false; diff --git a/frontend/src/app/features/dashboard/dashboard.component.spec.ts b/frontend/src/app/features/dashboard/dashboard.component.spec.ts index c5b968b..8665068 100644 --- a/frontend/src/app/features/dashboard/dashboard.component.spec.ts +++ b/frontend/src/app/features/dashboard/dashboard.component.spec.ts @@ -1,21 +1,49 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { CommonModule } from '@angular/common'; +import { ReactiveFormsModule } from '@angular/forms'; +import { ActivatedRoute, RouterLink } from '@angular/router'; +import { InvitationService } from '@core/services/invitation/invitation.service'; +import { ToastAlertService } from '@core/services/toast-alert/toast-alert.service'; import { UserService } from '@core/services/user/user.service'; +import { AppButtonComponent } from '@shared/app-button/app-button.component'; +import { AppCardComponent } from '@shared/app-card/app-card.component'; +import { AppFooterComponentMock } from 'src/__mocks__/components/app-footer.component.mock'; +import { AppHeaderComponentMock } from 'src/__mocks__/components/app-header.component.mock'; +import { ActivatedRouteMock } from 'src/__mocks__/services/activated-route.service.mock'; +import { InvitationServiceMock } from 'src/__mocks__/services/invitation.service.mock'; +import { ToastAlertServiceMock } from 'src/__mocks__/services/toast-alert.service.mock'; import { UserServiceMock } from 'src/__mocks__/services/user.service.mock'; +import { DashboardDialogInvitationsComponent } from './components/dashboard-dialog-invites/dashboard-dialog-invitations.component'; import { DashboardComponent } from './dashboard.component'; describe('DashboardComponent', () => { let component: DashboardComponent; let fixture: ComponentFixture; - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [DashboardComponent], - providers: [{ provide: UserService, useValue: UserServiceMock }], - }).compileComponents(); + beforeEach(() => { + TestBed.overrideComponent(DashboardComponent, { + set: { + imports: [ + CommonModule, + RouterLink, + ReactiveFormsModule, + AppCardComponent, + AppButtonComponent, + DashboardDialogInvitationsComponent, + AppHeaderComponentMock, + AppFooterComponentMock, + ], + providers: [ + { provide: UserService, useClass: UserServiceMock }, + { provide: ActivatedRoute, useClass: ActivatedRouteMock }, + { provide: ToastAlertService, useClass: ToastAlertServiceMock }, + { provide: InvitationService, useClass: InvitationServiceMock }, + ], + }, + }); fixture = TestBed.createComponent(DashboardComponent); - TestBed.inject(UserServiceMock); component = fixture.componentInstance; fixture.detectChanges(); }); diff --git a/frontend/src/app/features/dashboard/dashboard.component.ts b/frontend/src/app/features/dashboard/dashboard.component.ts index af3f3ce..62e5e99 100644 --- a/frontend/src/app/features/dashboard/dashboard.component.ts +++ b/frontend/src/app/features/dashboard/dashboard.component.ts @@ -1,7 +1,7 @@ import { CommonModule } from '@angular/common'; import { Component, effect, inject, signal } from '@angular/core'; import { ReactiveFormsModule } from '@angular/forms'; -import { RouterModule } from '@angular/router'; +import { RouterLink } from '@angular/router'; import { ProjectForUser, User } from '@core/interfaces/user.interface'; import { UserService } from '@core/services/user/user.service'; import { ResponseGetProjectsForUser } from '@core/services/user/user.service.types'; @@ -18,7 +18,7 @@ import { DashboardDialogInvitationsComponent } from './components/dashboard-dial standalone: true, imports: [ CommonModule, - RouterModule, + RouterLink, ReactiveFormsModule, AppHeaderComponent, AppFooterComponent, diff --git a/frontend/src/app/features/invitation/invitation.component.spec.ts b/frontend/src/app/features/invitation/invitation.component.spec.ts index 3818b12..1044633 100644 --- a/frontend/src/app/features/invitation/invitation.component.spec.ts +++ b/frontend/src/app/features/invitation/invitation.component.spec.ts @@ -1,15 +1,27 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { AuthService } from '@core/services/auth/auth.service'; +import { ToastAlertService } from '@core/services/toast-alert/toast-alert.service'; +import { UserService } from '@core/services/user/user.service'; +import { AuthServiceMock } from 'src/__mocks__/services/auth.service.mock'; +import { ToastAlertServiceMock } from 'src/__mocks__/services/toast-alert.service.mock'; +import { UserServiceMock } from 'src/__mocks__/services/user.service.mock'; import { InvitationComponent } from './invitation.component'; describe('InvitationComponent', () => { let component: InvitationComponent; let fixture: ComponentFixture; - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [InvitationComponent], - }).compileComponents(); + beforeEach(() => { + TestBed.overrideComponent(InvitationComponent, { + set: { + providers: [ + { provide: AuthService, useClass: AuthServiceMock }, + { provide: UserService, useClass: UserServiceMock }, + { provide: ToastAlertService, useClass: ToastAlertServiceMock }, + ], + }, + }); fixture = TestBed.createComponent(InvitationComponent); component = fixture.componentInstance; diff --git a/frontend/src/app/features/login/login.component.spec.ts b/frontend/src/app/features/login/login.component.spec.ts index 18f3685..6e71f2e 100644 --- a/frontend/src/app/features/login/login.component.spec.ts +++ b/frontend/src/app/features/login/login.component.spec.ts @@ -1,16 +1,31 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { FormBuilder } from '@angular/forms'; +import { Router } from '@angular/router'; +import { AuthService } from '@core/services/auth/auth.service'; +import { ToastAlertService } from '@core/services/toast-alert/toast-alert.service'; +import { UserService } from '@core/services/user/user.service'; +import { AuthServiceMock } from 'src/__mocks__/services/auth.service.mock'; +import { ToastAlertServiceMock } from 'src/__mocks__/services/toast-alert.service.mock'; +import { UserServiceMock } from 'src/__mocks__/services/user.service.mock'; import { LoginComponent } from './login.component'; describe('LoginComponent', () => { let component: LoginComponent; let fixture: ComponentFixture; - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [LoginComponent] - }) - .compileComponents(); + beforeEach(() => { + TestBed.overrideComponent(LoginComponent, { + set: { + providers: [ + FormBuilder, + Router, + { provide: AuthService, useClass: AuthServiceMock }, + { provide: UserService, useClass: UserServiceMock }, + { provide: ToastAlertService, useClass: ToastAlertServiceMock }, + ], + }, + }); fixture = TestBed.createComponent(LoginComponent); component = fixture.componentInstance; diff --git a/frontend/src/app/features/projects/view-project/view-project.component.spec.ts b/frontend/src/app/features/projects/view-project/view-project.component.spec.ts index 40fd26e..3a4b7dd 100644 --- a/frontend/src/app/features/projects/view-project/view-project.component.spec.ts +++ b/frontend/src/app/features/projects/view-project/view-project.component.spec.ts @@ -1,16 +1,53 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { AsyncPipe, DatePipe } from '@angular/common'; +import { Router, RouterLink } from '@angular/router'; +import { DialogConfirmationService } from '@core/services/dialog-confirmation/dialog-confirmation.service'; +import { ProjectService } from '@core/services/project/project.service'; +import { TaskService } from '@core/services/task/task.service'; +import { ToastAlertService } from '@core/services/toast-alert/toast-alert.service'; +import { AppButtonComponent } from '@shared/app-button/app-button.component'; +import { AppCardComponent } from '@shared/app-card/app-card.component'; +import { AppChipComponent } from '@shared/app-chip/app-chip.component'; +import { AppDividerComponent } from '@shared/app-divider/app-divider.component'; +import { AppFooterComponentMock } from 'src/__mocks__/components/app-footer.component.mock'; +import { AppHeaderComponentMock } from 'src/__mocks__/components/app-header.component.mock'; +import { DialogConfirmationServiceMock } from 'src/__mocks__/services/dialog-confirmation.service.mock'; +import { ProjectServiceMock } from 'src/__mocks__/services/project.service.mock'; +import { TaskServiceMock } from 'src/__mocks__/services/task.service.mock'; +import { ToastAlertServiceMock } from 'src/__mocks__/services/toast-alert.service.mock'; import { ViewProjectComponent } from './view-project.component'; describe('ViewProjectComponent', () => { let component: ViewProjectComponent; let fixture: ComponentFixture; - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [ViewProjectComponent] - }) - .compileComponents(); + beforeEach(() => { + TestBed.overrideComponent(ViewProjectComponent, { + set: { + imports: [ + AppHeaderComponentMock, + AppFooterComponentMock, + AppCardComponent, + AppChipComponent, + AppDividerComponent, + AppButtonComponent, + RouterLink, + AsyncPipe, + DatePipe, + ], + providers: [ + Router, + { provide: ProjectService, useClass: ProjectServiceMock }, + { provide: ToastAlertService, useClass: ToastAlertServiceMock }, + { + provide: DialogConfirmationService, + useClass: DialogConfirmationServiceMock, + }, + { provide: TaskService, useClass: TaskServiceMock }, + ], + }, + }); fixture = TestBed.createComponent(ViewProjectComponent); component = fixture.componentInstance; diff --git a/frontend/src/app/features/projects/view-project/view-project.component.ts b/frontend/src/app/features/projects/view-project/view-project.component.ts index 08bd8c2..ecd27ed 100644 --- a/frontend/src/app/features/projects/view-project/view-project.component.ts +++ b/frontend/src/app/features/projects/view-project/view-project.component.ts @@ -1,5 +1,5 @@ import { AsyncPipe, DatePipe } from '@angular/common'; -import { Component, inject, input, OnInit } from '@angular/core'; +import { Component, inject, Input, OnInit } from '@angular/core'; import { Router, RouterLink } from '@angular/router'; import { DialogConfirmationService } from '@core/services/dialog-confirmation/dialog-confirmation.service'; import { ProjectService } from '@core/services/project/project.service'; @@ -41,15 +41,15 @@ export class ViewProjectComponent implements OnInit { dialogConfirmationService = inject(DialogConfirmationService); router = inject(Router); taskService = inject(TaskService); - projectId = input.required(); + @Input({ required: true }) projectId: string = ''; PrimeIcons = PrimeIcons; getProject$!: Observable; getTasks$!: Observable; ngOnInit() { - this.getProject$ = this.projectService.getProject(this.projectId()); - this.getTasks$ = this.projectService.getTasksForProject(this.projectId()); + this.getProject$ = this.projectService.getProject(this.projectId); + this.getTasks$ = this.projectService.getTasksForProject(this.projectId); } confirmationDelete() { @@ -62,7 +62,7 @@ export class ViewProjectComponent implements OnInit { } deleteProject() { - this.projectService.deleteProject(this.projectId()).subscribe({ + this.projectService.deleteProject(this.projectId).subscribe({ next: (data) => { this.toastAlertService.addSuccessMessage({ title: 'Deleted project', diff --git a/frontend/src/app/features/register/register.component.spec.ts b/frontend/src/app/features/register/register.component.spec.ts index 757b895..aba980c 100644 --- a/frontend/src/app/features/register/register.component.spec.ts +++ b/frontend/src/app/features/register/register.component.spec.ts @@ -1,16 +1,31 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { FormBuilder } from '@angular/forms'; +import { Router } from '@angular/router'; +import { AuthService } from '@core/services/auth/auth.service'; +import { ToastAlertService } from '@core/services/toast-alert/toast-alert.service'; +import { UserService } from '@core/services/user/user.service'; +import { AuthServiceMock } from 'src/__mocks__/services/auth.service.mock'; +import { ToastAlertServiceMock } from 'src/__mocks__/services/toast-alert.service.mock'; +import { UserServiceMock } from 'src/__mocks__/services/user.service.mock'; import { RegisterComponent } from './register.component'; describe('RegisterComponent', () => { let component: RegisterComponent; let fixture: ComponentFixture; - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [RegisterComponent] - }) - .compileComponents(); + beforeEach(() => { + TestBed.overrideComponent(RegisterComponent, { + set: { + providers: [ + FormBuilder, + Router, + { provide: AuthService, useClass: AuthServiceMock }, + { provide: UserService, useClass: UserServiceMock }, + { provide: ToastAlertService, useClass: ToastAlertServiceMock }, + ], + }, + }); fixture = TestBed.createComponent(RegisterComponent); component = fixture.componentInstance; diff --git a/frontend/src/app/pages/invitation-page/invitation-page.component.spec.ts b/frontend/src/app/pages/invitation-page/invitation-page.component.spec.ts index c28180a..bd2c1d0 100644 --- a/frontend/src/app/pages/invitation-page/invitation-page.component.spec.ts +++ b/frontend/src/app/pages/invitation-page/invitation-page.component.spec.ts @@ -3,7 +3,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ActivatedRoute } from '@angular/router'; import { ToastAlertService } from '@core/services/toast-alert/toast-alert.service'; import { UserService } from '@core/services/user/user.service'; -import { InvitationStubComponent } from 'src/__mocks__/components/invitations.component.mock'; +import { InvitationComponentMock } from 'src/__mocks__/components/invitations.component.mock'; import { ActivatedRouteMock } from 'src/__mocks__/services/activated-route.service.mock'; import { ToastAlertServiceMock } from 'src/__mocks__/services/toast-alert.service.mock'; import { UserServiceMock } from 'src/__mocks__/services/user.service.mock'; @@ -24,7 +24,7 @@ describe('InvitationPageComponent', () => { ], }) .overrideComponent(InvitationPageComponent, { - set: { imports: [InvitationStubComponent] }, + set: { imports: [InvitationComponentMock] }, }) .compileComponents(); diff --git a/frontend/src/app/shared/app-chip/app-chip.component.spec.ts b/frontend/src/app/shared/app-chip/app-chip.component.spec.ts index 3e71d03..5e7246f 100644 --- a/frontend/src/app/shared/app-chip/app-chip.component.spec.ts +++ b/frontend/src/app/shared/app-chip/app-chip.component.spec.ts @@ -1,16 +1,18 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ChipModule } from 'primeng/chip'; import { AppChipComponent } from './app-chip.component'; describe('AppChipComponent', () => { let component: AppChipComponent; let fixture: ComponentFixture; - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [AppChipComponent] - }) - .compileComponents(); + beforeEach(() => { + TestBed.overrideComponent(AppChipComponent, { + set: { + imports: [ChipModule], + }, + }); fixture = TestBed.createComponent(AppChipComponent); component = fixture.componentInstance; diff --git a/frontend/src/app/shared/app-chip/app-chip.component.ts b/frontend/src/app/shared/app-chip/app-chip.component.ts index a4cd4c7..e1c5bd1 100644 --- a/frontend/src/app/shared/app-chip/app-chip.component.ts +++ b/frontend/src/app/shared/app-chip/app-chip.component.ts @@ -9,8 +9,8 @@ import { ChipModule } from 'primeng/chip'; styleUrl: './app-chip.component.scss', }) export class AppChipComponent { - label = input.required(); - icon = input(); - image = input(); - altImage = input(); + label = input(''); + icon = input(''); + image = input(''); + altImage = input(''); }