mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-01-22 04:18:08 +00:00
Merge pull request #406 from GNS3/Refresh-page-button-redirects-to-empty-page
Refresh page button redirects to empty page while in ElectronJS #371
This commit is contained in:
commit
64ad61c15b
@ -5,7 +5,7 @@ import { MatIconModule, MatProgressSpinnerModule } from '@angular/material';
|
|||||||
import { ProgressService } from './progress.service';
|
import { ProgressService } from './progress.service';
|
||||||
import { RouterTestingModule } from '@angular/router/testing';
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { BehaviorSubject } from 'rxjs';
|
import { BehaviorSubject, Observable } from 'rxjs';
|
||||||
|
|
||||||
class MockedRouter {
|
class MockedRouter {
|
||||||
events: BehaviorSubject<boolean>;
|
events: BehaviorSubject<boolean>;
|
||||||
@ -13,18 +13,20 @@ class MockedRouter {
|
|||||||
constructor() {
|
constructor() {
|
||||||
this.events = new BehaviorSubject(true);
|
this.events = new BehaviorSubject(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
navigateByUrl() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('ProgressComponent', () => {
|
describe('ProgressComponent', () => {
|
||||||
let component: ProgressComponent;
|
let component: ProgressComponent;
|
||||||
let fixture: ComponentFixture<ProgressComponent>;
|
let fixture: ComponentFixture<ProgressComponent>;
|
||||||
let progressService: ProgressService;
|
let progressService: ProgressService;
|
||||||
let router: MockedRouter;
|
let router: MockedRouter = new MockedRouter();
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [RouterTestingModule, MatProgressSpinnerModule, MatIconModule],
|
imports: [RouterTestingModule, MatProgressSpinnerModule, MatIconModule],
|
||||||
providers: [ProgressService, { provide: Router, useClass: MockedRouter }],
|
providers: [ProgressService, { provide: Router, useValue: router }],
|
||||||
declarations: [ProgressComponent]
|
declarations: [ProgressComponent]
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
|
|
||||||
@ -71,4 +73,12 @@ describe('ProgressComponent', () => {
|
|||||||
|
|
||||||
expect(progressService.clear).toHaveBeenCalled();
|
expect(progressService.clear).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should reload page after clicking refresh", () => {
|
||||||
|
spyOn(router, 'navigateByUrl');
|
||||||
|
|
||||||
|
component.refresh();
|
||||||
|
|
||||||
|
expect(router.navigateByUrl).toHaveBeenCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -36,8 +36,7 @@ export class ProgressComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
refresh() {
|
refresh() {
|
||||||
// unfortunately we need to use global var
|
this.router.navigateByUrl(this.router.url);
|
||||||
location.reload();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
|
Loading…
Reference in New Issue
Block a user