mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2024-12-18 20:47:51 +00:00
Stabilize unit tests #1010
This commit is contained in:
parent
165ab06fde
commit
99b90db6ed
1
debug.log
Normal file
1
debug.log
Normal file
@ -0,0 +1 @@
|
|||||||
|
[1109/003452.026:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
|
@ -0,0 +1,33 @@
|
|||||||
|
import { ConsoleWrapperComponent } from "./console-wrapper.component";
|
||||||
|
import { NodeConsoleService } from '../../../services/nodeConsole.service';
|
||||||
|
import { ThemeService } from '../../../services/theme.service';
|
||||||
|
import { MapSettingsService } from '../../../services/mapsettings.service';
|
||||||
|
|
||||||
|
describe('ConsoleWrapperComponent', () => {
|
||||||
|
it('should get actual theme', () => {
|
||||||
|
const consoleService = new NodeConsoleService();
|
||||||
|
|
||||||
|
const themeService = autoSpy(ThemeService);
|
||||||
|
themeService.getActualTheme.and.returnValue('light');
|
||||||
|
|
||||||
|
const mapSettingsService = autoSpy(MapSettingsService);
|
||||||
|
const component = new ConsoleWrapperComponent(consoleService, themeService, mapSettingsService);
|
||||||
|
|
||||||
|
component.ngOnInit();
|
||||||
|
|
||||||
|
expect(component.isLightThemeEnabled).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
export type SpyOf<T> = T & { [k in keyof T]: jasmine.Spy };
|
||||||
|
|
||||||
|
export function autoSpy<T>(obj: new (...args: any[]) => T): SpyOf<T> {
|
||||||
|
const res: SpyOf<T> = {} as any;
|
||||||
|
|
||||||
|
const keys = Object.getOwnPropertyNames(obj.prototype);
|
||||||
|
keys.forEach((key) => {
|
||||||
|
res[key] = jasmine.createSpy(key);
|
||||||
|
});
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
@ -17,7 +17,7 @@ import { Node } from '../../../cartography/models/node';
|
|||||||
import { ConsoleDeviceActionComponent } from '../context-menu/actions/console-device-action/console-device-action.component';
|
import { ConsoleDeviceActionComponent } from '../context-menu/actions/console-device-action/console-device-action.component';
|
||||||
import { ConsoleDeviceActionBrowserComponent } from '../context-menu/actions/console-device-action-browser/console-device-action-browser.component';
|
import { ConsoleDeviceActionBrowserComponent } from '../context-menu/actions/console-device-action-browser/console-device-action-browser.component';
|
||||||
|
|
||||||
fdescribe('ContextConsoleMenuComponent', () => {
|
describe('ContextConsoleMenuComponent', () => {
|
||||||
let component: ContextConsoleMenuComponent;
|
let component: ContextConsoleMenuComponent;
|
||||||
let fixture: ComponentFixture<ContextConsoleMenuComponent>;
|
let fixture: ComponentFixture<ContextConsoleMenuComponent>;
|
||||||
let toasterService: MockedToasterService = new MockedToasterService();
|
let toasterService: MockedToasterService = new MockedToasterService();
|
||||||
|
@ -76,7 +76,7 @@ describe('LogConsoleComponent', () => {
|
|||||||
|
|
||||||
component.handleCommand();
|
component.handleCommand();
|
||||||
|
|
||||||
expect(component.showMessage).toHaveBeenCalledWith({type: 'command', message: 'Current version: 2020.3.0-beta.4'});
|
expect(component.showMessage).toHaveBeenCalledWith({type: 'command', message: 'Current version: 2.2.16'});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call show message when unknown command entered', () => {
|
it('should call show message when unknown command entered', () => {
|
||||||
|
@ -15,6 +15,8 @@ import { ToasterService } from '../../services/toaster.service';
|
|||||||
import { MockedToasterService } from '../../services/toaster.service.spec';
|
import { MockedToasterService } from '../../services/toaster.service.spec';
|
||||||
import { ConsoleService } from '../../services/settings/console.service';
|
import { ConsoleService } from '../../services/settings/console.service';
|
||||||
import { MapSettingsService } from '../../services/mapsettings.service';
|
import { MapSettingsService } from '../../services/mapsettings.service';
|
||||||
|
import { UpdatesService } from '../../services/updates.service';
|
||||||
|
import { autoSpy } from '../project-map/console-wrapper/console-wrapper.component.spec';
|
||||||
|
|
||||||
describe('SettingsComponent', () => {
|
describe('SettingsComponent', () => {
|
||||||
let component: SettingsComponent;
|
let component: SettingsComponent;
|
||||||
@ -25,6 +27,7 @@ describe('SettingsComponent', () => {
|
|||||||
toggleIntegrateInterfaceLabels(val: boolean) {}
|
toggleIntegrateInterfaceLabels(val: boolean) {}
|
||||||
};
|
};
|
||||||
let consoleService;
|
let consoleService;
|
||||||
|
let updatesService = autoSpy(UpdatesService);
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
consoleService = {
|
consoleService = {
|
||||||
@ -37,7 +40,8 @@ describe('SettingsComponent', () => {
|
|||||||
SettingsService,
|
SettingsService,
|
||||||
{ provide: ToasterService, useClass: MockedToasterService },
|
{ provide: ToasterService, useClass: MockedToasterService },
|
||||||
{ provide: ConsoleService, useValue: consoleService },
|
{ provide: ConsoleService, useValue: consoleService },
|
||||||
{ provide: MapSettingsService, useValue: mapSettingsService }
|
{ provide: MapSettingsService, useValue: mapSettingsService },
|
||||||
|
{ provide: UpdatesService, useValue: updatesService }
|
||||||
],
|
],
|
||||||
declarations: [SettingsComponent]
|
declarations: [SettingsComponent]
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
|
@ -150,6 +150,7 @@ describe('ServerService', () => {
|
|||||||
expectedServer.host = 'hostname';
|
expectedServer.host = 'hostname';
|
||||||
expectedServer.port = 9999;
|
expectedServer.port = 9999;
|
||||||
expectedServer.location = 'bundled';
|
expectedServer.location = 'bundled';
|
||||||
|
expectedServer.protocol = 'http:';
|
||||||
|
|
||||||
service.getLocalServer('hostname', 9999).then(() => {
|
service.getLocalServer('hostname', 9999).then(() => {
|
||||||
expect(service.create).toHaveBeenCalledWith(expectedServer);
|
expect(service.create).toHaveBeenCalledWith(expectedServer);
|
||||||
|
Loading…
Reference in New Issue
Block a user