mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-06-14 04:58:07 +00:00
Tests for default layout component
This commit is contained in:
@ -1,14 +1,35 @@
|
|||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
import { DefaultLayoutComponent } from './default-layout.component';
|
import { DefaultLayoutComponent } from './default-layout.component';
|
||||||
|
import { ElectronService } from 'ngx-electron';
|
||||||
|
import { MatIconModule, MatMenuModule, MatToolbarModule, MatProgressSpinnerModule } from '@angular/material';
|
||||||
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
|
import { ProgressComponent } from '../../common/progress/progress.component';
|
||||||
|
import { ProgressService } from '../../common/progress/progress.service';
|
||||||
|
|
||||||
|
|
||||||
|
class ElectronServiceMock {
|
||||||
|
public isElectronApp: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
describe('DefaultLayoutComponent', () => {
|
describe('DefaultLayoutComponent', () => {
|
||||||
let component: DefaultLayoutComponent;
|
let component: DefaultLayoutComponent;
|
||||||
let fixture: ComponentFixture<DefaultLayoutComponent>;
|
let fixture: ComponentFixture<DefaultLayoutComponent>;
|
||||||
|
let electronServiceMock: ElectronServiceMock;
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
|
electronServiceMock = new ElectronServiceMock();
|
||||||
|
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
declarations: [DefaultLayoutComponent]
|
declarations: [DefaultLayoutComponent, ProgressComponent],
|
||||||
|
imports: [MatIconModule, MatMenuModule, MatToolbarModule, RouterTestingModule, MatProgressSpinnerModule],
|
||||||
|
providers: [
|
||||||
|
{
|
||||||
|
provide: ElectronService,
|
||||||
|
useValue: electronServiceMock
|
||||||
|
},
|
||||||
|
ProgressService
|
||||||
|
]
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -18,7 +39,19 @@ describe('DefaultLayoutComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
// it('should create', () => {
|
it('should create', () => {
|
||||||
// expect(component).toBeTruthy();
|
expect(component).toBeTruthy();
|
||||||
// });
|
});
|
||||||
|
|
||||||
|
it('should installed software be available', () => {
|
||||||
|
electronServiceMock.isElectronApp = true;
|
||||||
|
component.ngOnInit();
|
||||||
|
expect(component.isInstalledSoftwareAvailable).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should installed software be not available', () => {
|
||||||
|
electronServiceMock.isElectronApp = false;
|
||||||
|
component.ngOnInit();
|
||||||
|
expect(component.isInstalledSoftwareAvailable).toBeFalsy();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -12,7 +12,7 @@ export class DefaultLayoutComponent implements OnInit {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private electronService: ElectronService
|
private electronService: ElectronService
|
||||||
) { }
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.isInstalledSoftwareAvailable = this.electronService.isElectronApp;
|
this.isInstalledSoftwareAvailable = this.electronService.isElectronApp;
|
||||||
|
Reference in New Issue
Block a user