mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-01-21 20:08: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 { 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();
|
||||
});
|
||||
});
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user