mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-06-22 16:39:00 +00:00
Progress error status, Fixes: #146
This commit is contained in:
@ -1,25 +1,45 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ProgressComponent } from './progress.component';
|
||||
import { MatProgressSpinnerModule } from "@angular/material";
|
||||
import { MatIconModule, MatProgressSpinnerModule } from "@angular/material";
|
||||
import { ProgressService } from "./progress.service";
|
||||
import { RouterTestingModule } from "@angular/router/testing";
|
||||
import { Router } from "@angular/router";
|
||||
import { BehaviorSubject } from "rxjs/BehaviorSubject";
|
||||
|
||||
|
||||
class MockedRouter {
|
||||
events: BehaviorSubject<boolean>;
|
||||
|
||||
constructor() {
|
||||
this.events = new BehaviorSubject(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
describe('ProgressComponent', () => {
|
||||
let component: ProgressComponent;
|
||||
let fixture: ComponentFixture<ProgressComponent>;
|
||||
let progressService: ProgressService;
|
||||
let router: MockedRouter;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
RouterTestingModule,
|
||||
MatProgressSpinnerModule,
|
||||
MatIconModule
|
||||
],
|
||||
providers: [
|
||||
ProgressService,
|
||||
{ provide: Router, useClass: MockedRouter}
|
||||
],
|
||||
providers: [ ProgressService ],
|
||||
declarations: [ ProgressComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
progressService = TestBed.get(ProgressService);
|
||||
router = TestBed.get(Router);
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
@ -45,4 +65,21 @@ describe('ProgressComponent', () => {
|
||||
expect(component.visible).toEqual(false);
|
||||
});
|
||||
|
||||
it( 'should set error state when error defined', () => {
|
||||
const error = new Error("test");
|
||||
progressService.setError(error);
|
||||
expect(component.error).toEqual(error);
|
||||
});
|
||||
|
||||
it( 'should clear error when changes route', () => {
|
||||
const error = new Error("test");
|
||||
component.error = error;
|
||||
|
||||
spyOn(progressService, 'clear');
|
||||
|
||||
router.events.next(true);
|
||||
|
||||
expect(progressService.clear).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user