mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-01-30 16:13:55 +00:00
Resolve Unit test case issues
This commit is contained in:
parent
2a44abadd5
commit
5bb61bd1bc
@ -1,21 +1,24 @@
|
|||||||
|
import { HttpClientModule } from '@angular/common/http';
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
import { MatDialogModule, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||||
import { MatIconModule } from '@angular/material/icon';
|
import { MatIconModule } from '@angular/material/icon';
|
||||||
import { MatMenuModule } from '@angular/material/menu';
|
import { MatMenuModule } from '@angular/material/menu';
|
||||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||||
import { MatToolbarModule } from '@angular/material/toolbar';
|
import { MatToolbarModule } from '@angular/material/toolbar';
|
||||||
import { RouterTestingModule } from '@angular/router/testing';
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
import { ControllerService } from '../../services/controller.service';
|
import { ProjectService } from '../../services/project.service';
|
||||||
|
import { MockedProjectService } from '../../services/project.service.spec';
|
||||||
import { ElectronService } from 'ngx-electron';
|
import { ElectronService } from 'ngx-electron';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
import { ProgressComponent } from '../../common/progress/progress.component';
|
import { ProgressComponent } from '../../common/progress/progress.component';
|
||||||
import { ProgressService } from '../../common/progress/progress.service';
|
import { ProgressService } from '../../common/progress/progress.service';
|
||||||
import { RecentlyOpenedProjectService } from '../../services/recentlyOpenedProject.service';
|
|
||||||
import { ControllerManagementService, ControllerStateEvent } from '../../services/controller-management.service';
|
import { ControllerManagementService, ControllerStateEvent } from '../../services/controller-management.service';
|
||||||
|
import { ControllerService } from '../../services/controller.service';
|
||||||
|
import { ControllerErrorHandler, HttpController } from '../../services/http-controller.service';
|
||||||
|
import { RecentlyOpenedProjectService } from '../../services/recentlyOpenedProject.service';
|
||||||
import { ToasterService } from '../../services/toaster.service';
|
import { ToasterService } from '../../services/toaster.service';
|
||||||
import { MockedToasterService } from '../../services/toaster.service.spec';
|
import { MockedToasterService } from '../../services/toaster.service.spec';
|
||||||
import { DefaultLayoutComponent } from './default-layout.component';
|
import { DefaultLayoutComponent } from './default-layout.component';
|
||||||
import { HttpController, ControllerErrorHandler } from '../../services/http-controller.service';
|
|
||||||
import { HttpClientModule } from '@angular/common/http';
|
|
||||||
|
|
||||||
class ElectronServiceMock {
|
class ElectronServiceMock {
|
||||||
public isElectronApp: boolean;
|
public isElectronApp: boolean;
|
||||||
@ -35,13 +38,21 @@ describe('DefaultLayoutComponent', () => {
|
|||||||
let httpController: HttpController;
|
let httpController: HttpController;
|
||||||
let errorHandler: ControllerErrorHandler;
|
let errorHandler: ControllerErrorHandler;
|
||||||
|
|
||||||
beforeEach(async() => {
|
beforeEach(async () => {
|
||||||
electronServiceMock = new ElectronServiceMock();
|
electronServiceMock = new ElectronServiceMock();
|
||||||
controllerManagementService.controllerStatusChanged = new Subject<ControllerStateEvent>();
|
controllerManagementService.controllerStatusChanged = new Subject<ControllerStateEvent>();
|
||||||
|
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
declarations: [DefaultLayoutComponent, ProgressComponent],
|
declarations: [DefaultLayoutComponent, ProgressComponent],
|
||||||
imports: [MatIconModule, MatMenuModule, MatToolbarModule, HttpClientModule, RouterTestingModule, MatProgressSpinnerModule],
|
imports: [
|
||||||
|
MatIconModule,
|
||||||
|
MatMenuModule,
|
||||||
|
MatDialogModule,
|
||||||
|
MatToolbarModule,
|
||||||
|
HttpClientModule,
|
||||||
|
RouterTestingModule,
|
||||||
|
MatProgressSpinnerModule,
|
||||||
|
],
|
||||||
providers: [
|
providers: [
|
||||||
{
|
{
|
||||||
provide: ElectronService,
|
provide: ElectronService,
|
||||||
@ -51,6 +62,8 @@ describe('DefaultLayoutComponent', () => {
|
|||||||
provide: ControllerManagementService,
|
provide: ControllerManagementService,
|
||||||
useValue: controllerManagementService,
|
useValue: controllerManagementService,
|
||||||
},
|
},
|
||||||
|
{ provide: ProjectService, useClass: MockedProjectService },
|
||||||
|
|
||||||
{
|
{
|
||||||
provide: ToasterService,
|
provide: ToasterService,
|
||||||
useClass: MockedToasterService,
|
useClass: MockedToasterService,
|
||||||
@ -62,6 +75,8 @@ describe('DefaultLayoutComponent', () => {
|
|||||||
{ provide: ControllerService },
|
{ provide: ControllerService },
|
||||||
{ provide: HttpController },
|
{ provide: HttpController },
|
||||||
{ provide: ControllerErrorHandler },
|
{ provide: ControllerErrorHandler },
|
||||||
|
{ provide: MatDialogRef, useValue: {}},
|
||||||
|
{ provide: MAT_DIALOG_DATA, useValue: {}},
|
||||||
ProgressService,
|
ProgressService,
|
||||||
],
|
],
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user