mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-04-24 21:09:40 +00:00
Unit tests added
This commit is contained in:
parent
d594fc0a36
commit
98c079175f
@ -11,6 +11,8 @@ import { SettingsService } from '../../../../../services/settings.service';
|
||||
import { MockedSettingsService } from '../../../../../services/settings.service.spec';
|
||||
import { Node } from '../../../../../cartography/models/node';
|
||||
import { Server } from '../../../../../models/server';
|
||||
import { MockedNodeService } from '../../../project-map.component.spec';
|
||||
import { NodeService } from '../../../../../services/node.service';
|
||||
|
||||
|
||||
describe('ConsoleDeviceActionComponent', () => {
|
||||
@ -20,7 +22,8 @@ describe('ConsoleDeviceActionComponent', () => {
|
||||
let server: Server;
|
||||
let mockedSettingsService: MockedSettingsService;
|
||||
let mockedServerService: MockedServerService;
|
||||
let mockedToaster: MockedToasterService
|
||||
let mockedToaster: MockedToasterService;
|
||||
let mockedNodeService: MockedNodeService = new MockedNodeService();
|
||||
|
||||
beforeEach(() => {
|
||||
electronService = {
|
||||
@ -47,7 +50,8 @@ describe('ConsoleDeviceActionComponent', () => {
|
||||
{ provide: ElectronService, useValue: electronService },
|
||||
{ provide: ServerService, useValue: mockedServerService },
|
||||
{ provide: SettingsService, useValue: mockedSettingsService },
|
||||
{ provide: ToasterService, useValue: mockedToaster }
|
||||
{ provide: ToasterService, useValue: mockedToaster },
|
||||
{ provide: NodeService, useValue: mockedNodeService }
|
||||
],
|
||||
imports: [
|
||||
MatIconModule
|
||||
|
@ -5,6 +5,7 @@ import { ElectronService } from 'ngx-electron';
|
||||
import { ServerService } from '../../../../../services/server.service';
|
||||
import { SettingsService } from '../../../../../services/settings.service';
|
||||
import { ToasterService } from '../../../../../services/toaster.service';
|
||||
import { NodeService } from '../../../../../services/node.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-console-device-action',
|
||||
@ -18,19 +19,14 @@ export class ConsoleDeviceActionComponent implements OnInit {
|
||||
private electronService: ElectronService,
|
||||
private serverService: ServerService,
|
||||
private settingsService: SettingsService,
|
||||
private toasterService: ToasterService
|
||||
private toasterService: ToasterService,
|
||||
private nodeService: NodeService
|
||||
) { }
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
ngOnInit() {}
|
||||
|
||||
async console() {
|
||||
let consoleCommand = this.settingsService.get<string>('console_command');
|
||||
|
||||
if(consoleCommand === undefined) {
|
||||
consoleCommand = `putty.exe -telnet \%h \%p -wt \"\%d\" -gns3 5 -skin 4`;
|
||||
}
|
||||
|
||||
let consoleCommand = this.settingsService.get<string>('console_command') ? this.settingsService.get<string>('console_command') : this.nodeService.getDefaultCommand();
|
||||
const startedNodes = this.nodes.filter(node => node.status === 'started');
|
||||
|
||||
if(startedNodes.length === 0) {
|
||||
|
@ -28,10 +28,7 @@ export class NodesMenuComponent {
|
||||
|
||||
async startConsoleForAllNodes() {
|
||||
if (this.electronService.isElectronApp) {
|
||||
let consoleCommand = this.settingsService.get<string>('console_command');
|
||||
if(consoleCommand === undefined) {
|
||||
consoleCommand = `putty.exe -telnet \%h \%p -wt \"\%d\" -gns3 5 -skin 4`;
|
||||
}
|
||||
let consoleCommand = this.settingsService.get<string>('console_command') ? this.settingsService.get<string>('console_command') : this.nodeService.getDefaultCommand();
|
||||
|
||||
let nodes = this.nodesDataSource.getItems();
|
||||
for(var node of nodes) {
|
||||
|
@ -64,6 +64,10 @@ export class MockedProgressService {
|
||||
export class MockedNodeService {
|
||||
public node = { label: {} } as Node;
|
||||
constructor() {}
|
||||
|
||||
getDefaultCommand(): string {
|
||||
return `putty.exe -telnet \%h \%p -wt \"\%d\" -gns3 5 -skin 4`;
|
||||
}
|
||||
|
||||
updateLabel(): Observable<Node> {
|
||||
return of(this.node);
|
||||
|
@ -122,6 +122,10 @@ export class NodeService {
|
||||
return this.httpServer.get(server, `/projects/${node.project_id}/nodes/${node.node_id}`)
|
||||
}
|
||||
|
||||
getDefaultCommand(): string {
|
||||
return `putty.exe -telnet \%h \%p -wt \"\%d\" -gns3 5 -skin 4`;
|
||||
}
|
||||
|
||||
getConfiguration(server: Server, node: Node) {
|
||||
let urlPath: string = `/projects/${node.project_id}/nodes/${node.node_id}`
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user