Skip to content

Commit

Permalink
fix: 🐛 catch edge case where some plugins not loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
thkruz committed Aug 11, 2024
1 parent 69b53ca commit 0db9fd0
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/plugins/sensor-fov/sensor-fov.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class SensorFov extends KeepTrackPlugin {
}

public enableFovView() {
keepTrackApi.getPlugin(SensorSurvFence).setBottomIconToUnselected();
keepTrackApi.getPlugin(SensorSurvFence)?.setBottomIconToUnselected();

this.setBottomIconToSelected();
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/sensor-surv/sensor-surv-fence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class SensorSurvFence extends KeepTrackPlugin {
}

private enableSurvView_() {
keepTrackApi.getPlugin(SensorFov).setBottomIconToUnselected();
keepTrackApi.getPlugin(SensorFov)?.setBottomIconToUnselected();
this.setBottomIconToSelected();
}

Expand Down
48 changes: 24 additions & 24 deletions test/camera.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,16 +386,16 @@ const testVariousKeyDownInputs = (testFunc: () => void, cameraInstance: Camera)
cameraInstance.keyDownE_();
testFunc();

cameraInstance.keyDownI_();
cameraInstance.keyDownArrowDown_();
testFunc();

cameraInstance.keyDownJ_();
cameraInstance.keyDownArrowLeft_();
testFunc();

cameraInstance.keyDownK_();
cameraInstance.keyDownArrowRight_();
testFunc();

cameraInstance.keyDownL_();
cameraInstance.keyDownArrowUp_();
testFunc();

cameraInstance.keyDownQ_();
Expand Down Expand Up @@ -426,12 +426,12 @@ const testVariousKeyDownInputs = (testFunc: () => void, cameraInstance: Camera)
cameraInstance.keyDownE_();
testFunc();

cameraInstance.keyDownI_();
cameraInstance.keyDownJ_();
cameraInstance.keyDownArrowUp_();
cameraInstance.keyDownArrowDown_();
testFunc();

cameraInstance.keyDownK_();
cameraInstance.keyDownL_();
cameraInstance.keyDownArrowLeft_();
cameraInstance.keyDownArrowRight_();
testFunc();

cameraInstance.keyDownShift_();
Expand All @@ -452,16 +452,16 @@ const testVariousKeyUpInputs = (testFunc: () => void, cameraInstance: Camera) =>
cameraInstance.keyUpE_();
testFunc();

cameraInstance.keyUpI_();
cameraInstance.keyUpArrowUp_();
testFunc();

cameraInstance.keyUpJ_();
cameraInstance.keyUpArrowDown_();
testFunc();

cameraInstance.keyUpK_();
cameraInstance.keyUpArrowLeft_();
testFunc();

cameraInstance.keyUpL_();
cameraInstance.keyUpArrowRight_();
testFunc();

cameraInstance.keyUpQ_();
Expand Down Expand Up @@ -489,12 +489,12 @@ const testVariousKeyUpInputs = (testFunc: () => void, cameraInstance: Camera) =>
cameraInstance.keyUpE_();
testFunc();

cameraInstance.keyUpI_();
cameraInstance.keyUpJ_();
cameraInstance.keyUpArrowUp_();
cameraInstance.keyUpArrowDown_();
testFunc();

cameraInstance.keyUpK_();
cameraInstance.keyUpL_();
cameraInstance.keyUpArrowLeft_();
cameraInstance.keyUpArrowRight_();
testFunc();

cameraInstance.keyUpShift_();
Expand All @@ -516,12 +516,12 @@ const testVariousKeyCombinationInputs = (testFunc: () => void, cameraInstance: C
cameraInstance.keyUpE_();
testFunc();

cameraInstance.keyDownI_();
cameraInstance.keyUpJ_();
cameraInstance.keyDownArrowUp_();
cameraInstance.keyUpArrowDown_();
testFunc();

cameraInstance.keyDownK_();
cameraInstance.keyUpL_();
cameraInstance.keyDownArrowLeft_();
cameraInstance.keyUpArrowRight_();
testFunc();

cameraInstance.keyDownShift_();
Expand All @@ -541,12 +541,12 @@ const testVariousKeyCombinationInputs = (testFunc: () => void, cameraInstance: C
cameraInstance.keyDownE_();
testFunc();

cameraInstance.keyUpI_();
cameraInstance.keyDownJ_();
cameraInstance.keyUpArrowUp_();
cameraInstance.keyUpArrowDown_();
testFunc();

cameraInstance.keyUpK_();
cameraInstance.keyDownL_();
cameraInstance.keyUpArrowLeft_();
cameraInstance.keyUpArrowRight_();
testFunc();

cameraInstance.keyUpShift_();
Expand Down
5 changes: 4 additions & 1 deletion test/keyboard-input.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ describe('KeyboardInput_class', () => {
const keyboardInput = new KeyboardInput();

keyboardInput.init();
keyboardInput.registerKeyEvent('R', () => console.log('R pressed'));
keyboardInput.registerKeyEvent({
key: 'R',
callback: () => console.log('R pressed'),
});
expect(keyboardInput.keyEvents.length).toBe(1);
});
});

0 comments on commit 0db9fd0

Please sign in to comment.