Virtual ports tested
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Nathan Kellenicki 2020-01-09 10:56:59 -08:00
parent bf721eddf6
commit b43b59e526
2 changed files with 3 additions and 11 deletions

View File

@ -188,7 +188,7 @@ export class BaseHub extends EventEmitter {
if (portId !== undefined) { if (portId !== undefined) {
return this._attachedDevices[portId]; return this._attachedDevices[portId];
} else { } else {
throw new Error(`Port ${portName} does not exist on this hub type`); return undefined;
} }
} }

View File

@ -95,19 +95,11 @@ export class LPF2Hub extends BaseHub {
public createVirtualPort (firstPortName: string, secondPortName: string) { public createVirtualPort (firstPortName: string, secondPortName: string) {
const firstPortId = this._portMap[firstPortName]; const firstDevice = this.getDeviceAtPort(firstPortName);
if (!firstPortId) {
throw new Error(`Port ${firstPortName} does not exist on this hub`);
}
const secondPortId = this._portMap[secondPortName];
if (!secondPortId) {
throw new Error(`Port ${secondPortName} does not exist on this hub`);
}
const firstDevice = this._getDeviceByPortId(firstPortId);
if (!firstDevice) { if (!firstDevice) {
throw new Error(`Port ${firstPortName} does not have an attached device`); throw new Error(`Port ${firstPortName} does not have an attached device`);
} }
const secondDevice = this._getDeviceByPortId(secondPortId); const secondDevice = this.getDeviceAtPort(secondPortName);
if (!secondDevice) { if (!secondDevice) {
throw new Error(`Port ${secondPortName} does not have an attached device`); throw new Error(`Port ${secondPortName} does not have an attached device`);
} }