mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2024-12-19 13:07:52 +00:00
PlatformService tests
This commit is contained in:
parent
65acfbb11c
commit
ed204d3229
@ -1,12 +1,57 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { PlatformService } from './platform.service';
|
||||
import { ElectronService } from 'ngx-electron';
|
||||
|
||||
class ElectronServiceMock {
|
||||
process = {
|
||||
platform: 'unknown'
|
||||
};
|
||||
}
|
||||
|
||||
describe('PlatformService', () => {
|
||||
beforeEach(() => TestBed.configureTestingModule({}));
|
||||
let electronServiceMock: ElectronServiceMock;
|
||||
let service: PlatformService;
|
||||
|
||||
beforeEach(() => {
|
||||
electronServiceMock = new ElectronServiceMock();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [
|
||||
PlatformService,
|
||||
{provide: ElectronService, useValue: electronServiceMock}
|
||||
]
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
service = TestBed.get(PlatformService);
|
||||
})
|
||||
|
||||
it('should be created', () => {
|
||||
const service: PlatformService = TestBed.get(PlatformService);
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should be on windows platform', () => {
|
||||
electronServiceMock.process.platform = 'win32';
|
||||
expect(service.isWindows()).toBeTruthy();
|
||||
expect(service.isDarwin()).toBeFalsy();
|
||||
expect(service.isLinux()).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should be on linux platform', () => {
|
||||
electronServiceMock.process.platform = 'linux';
|
||||
expect(service.isWindows()).toBeFalsy();
|
||||
expect(service.isDarwin()).toBeFalsy();
|
||||
expect(service.isLinux()).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should be on darwin platform', () => {
|
||||
electronServiceMock.process.platform = 'darwin';
|
||||
expect(service.isWindows()).toBeFalsy();
|
||||
expect(service.isDarwin()).toBeTruthy();
|
||||
expect(service.isLinux()).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user