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:
ziajka 2019-05-29 07:58:13 +02:00 committed by GitHub
commit 64ad61c15b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 5 deletions

View File

@ -5,7 +5,7 @@ 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';
import { BehaviorSubject, Observable } from 'rxjs';
class MockedRouter {
events: BehaviorSubject<boolean>;
@ -13,18 +13,20 @@ class MockedRouter {
constructor() {
this.events = new BehaviorSubject(true);
}
navigateByUrl() {}
}
describe('ProgressComponent', () => {
let component: ProgressComponent;
let fixture: ComponentFixture<ProgressComponent>;
let progressService: ProgressService;
let router: MockedRouter;
let router: MockedRouter = new MockedRouter();
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [RouterTestingModule, MatProgressSpinnerModule, MatIconModule],
providers: [ProgressService, { provide: Router, useClass: MockedRouter }],
providers: [ProgressService, { provide: Router, useValue: router }],
declarations: [ProgressComponent]
}).compileComponents();
@ -71,4 +73,12 @@ describe('ProgressComponent', () => {
expect(progressService.clear).toHaveBeenCalled();
});
it("should reload page after clicking refresh", () => {
spyOn(router, 'navigateByUrl');
component.refresh();
expect(router.navigateByUrl).toHaveBeenCalled();
});
});

View File

@ -36,8 +36,7 @@ export class ProgressComponent implements OnInit, OnDestroy {
}
refresh() {
// unfortunately we need to use global var
location.reload();
this.router.navigateByUrl(this.router.url);
}
ngOnDestroy() {