mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-06-20 23:55:04 +00:00
PlatformService tests
This commit is contained in:
@ -1,12 +1,57 @@
|
|||||||
import { TestBed } from '@angular/core/testing';
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
import { PlatformService } from './platform.service';
|
import { PlatformService } from './platform.service';
|
||||||
|
import { ElectronService } from 'ngx-electron';
|
||||||
|
|
||||||
|
class ElectronServiceMock {
|
||||||
|
process = {
|
||||||
|
platform: 'unknown'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
describe('PlatformService', () => {
|
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', () => {
|
it('should be created', () => {
|
||||||
const service: PlatformService = TestBed.get(PlatformService);
|
|
||||||
expect(service).toBeTruthy();
|
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();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user