From 845f1f1ad8841a144d5d62f58facb205400af221 Mon Sep 17 00:00:00 2001 From: Rajnikant Lodhi Date: Tue, 19 Jul 2022 18:18:46 +0530 Subject: [PATCH] I complete unit test case to confirmations for delete all project --- ...tion-delete-all-projects.component.spec.ts | 29 +++++++++++++++++++ ...firmation-delete-all-projects.component.ts | 4 +-- .../components/projects/projects.component.ts | 2 +- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/app/components/projects/confirmation-delete-all-projects/confirmation-delete-all-projects.component.spec.ts b/src/app/components/projects/confirmation-delete-all-projects/confirmation-delete-all-projects.component.spec.ts index 8acf87e4..0b9f4d37 100644 --- a/src/app/components/projects/confirmation-delete-all-projects/confirmation-delete-all-projects.component.spec.ts +++ b/src/app/components/projects/confirmation-delete-all-projects/confirmation-delete-all-projects.component.spec.ts @@ -1,13 +1,42 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { MatCheckboxModule } from '@angular/material/checkbox'; +import { MatDialogModule, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; +import { MatIconModule } from '@angular/material/icon'; +import { MatMenuModule } from '@angular/material/menu'; +import { MatToolbarModule } from '@angular/material/toolbar'; +import { MockedProjectService } from '../../../services/project.service.spec'; +import { MockedToasterService } from '../../../services/toaster.service.spec'; +import { ProjectService } from '../../../services/project.service'; +import { ServerService } from '../../../services/server.service'; +import { MockedServerService } from '../../../services/server.service.spec'; +import { ToasterService } from '../../../services/toaster.service'; import { ConfirmationDeleteAllProjectsComponent } from './confirmation-delete-all-projects.component'; describe('ConfirmationDeleteAllProjectsComponent', () => { let component: ConfirmationDeleteAllProjectsComponent; let fixture: ComponentFixture; + let mockedServerService = new MockedServerService(); + let mockedImageManagerService = new MockedProjectService() + let mockedToasterService = new MockedToasterService() beforeEach(async () => { await TestBed.configureTestingModule({ + imports: [ + MatIconModule, + MatToolbarModule, + MatMenuModule, + MatCheckboxModule, + MatDialogModule, + ], + providers: [ + { provide: ServerService, useValue: mockedServerService }, + { provide: ProjectService, useValue: mockedImageManagerService }, + { provide: MAT_DIALOG_DATA, useValue: {} }, + { provide: MatDialogRef, useValue: {} }, + { provide: ToasterService, useValue: mockedToasterService }, + + ], declarations: [ ConfirmationDeleteAllProjectsComponent ] }) .compileComponents(); diff --git a/src/app/components/projects/confirmation-delete-all-projects/confirmation-delete-all-projects.component.ts b/src/app/components/projects/confirmation-delete-all-projects/confirmation-delete-all-projects.component.ts index 19d4b136..a28b2bb2 100644 --- a/src/app/components/projects/confirmation-delete-all-projects/confirmation-delete-all-projects.component.ts +++ b/src/app/components/projects/confirmation-delete-all-projects/confirmation-delete-all-projects.component.ts @@ -1,7 +1,7 @@ import { Component, Inject, OnInit } from '@angular/core'; import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; -import { ProjectService } from '@services/project.service'; -import { ToasterService } from '@services/toaster.service'; +import { ProjectService } from '../../../services/project.service'; +import { ToasterService } from '../../../services/toaster.service'; import { Observable, of } from 'rxjs'; import { catchError } from 'rxjs/operators'; diff --git a/src/app/components/projects/projects.component.ts b/src/app/components/projects/projects.component.ts index f88065d8..09a84403 100644 --- a/src/app/components/projects/projects.component.ts +++ b/src/app/components/projects/projects.component.ts @@ -4,7 +4,7 @@ import { MatBottomSheet } from '@angular/material/bottom-sheet'; import { MatDialog } from '@angular/material/dialog'; import { MatSort, MatSortable } from '@angular/material/sort'; import { ActivatedRoute, Router } from '@angular/router'; -import { ExportPortableProjectComponent } from '@components/export-portable-project/export-portable-project.component'; +import { ExportPortableProjectComponent } from '../../components/export-portable-project/export-portable-project.component'; import { ElectronService } from 'ngx-electron'; import { BehaviorSubject, merge, Observable } from 'rxjs'; import { map } from 'rxjs//operators';