Improve the look of the keyboard settings tab (#7562)
* First cut of new keyboard shortcuts Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Remove unused code Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * i18n Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Amend shortcuts Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Improve CATEGORIES struct Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Add tests for registerShortcut() Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Simplifie code tiny bit Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Translate ALTERNATE_KEY_NAME Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Fix `key` usage Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Export components for tests Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Write snapshot tests Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
45
test/accessibility/KeyboardShortcuts-test.ts
Normal file
45
test/accessibility/KeyboardShortcuts-test.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
Copyright 2022 Šimon Brandner <simon.bra.ag@gmail.com>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import {
|
||||
CATEGORIES,
|
||||
CategoryName,
|
||||
KEYBOARD_SHORTCUTS,
|
||||
registerShortcut,
|
||||
} from "../../src/accessibility/KeyboardShortcuts";
|
||||
import { Key } from "../../src/Keyboard";
|
||||
import { ISetting } from "../../src/settings/Settings";
|
||||
|
||||
describe("KeyboardShortcuts", () => {
|
||||
describe("registerShortcut()", () => {
|
||||
it("correctly registers shortcut", () => {
|
||||
const shortcutName = "Keybinding.definitelyARealShortcut";
|
||||
const shortcutCategory = CategoryName.NAVIGATION;
|
||||
const shortcut: ISetting = {
|
||||
displayName: "A real shortcut",
|
||||
default: {
|
||||
ctrlKey: true,
|
||||
key: Key.A,
|
||||
},
|
||||
};
|
||||
|
||||
registerShortcut(shortcutName, shortcutCategory, shortcut);
|
||||
|
||||
expect(KEYBOARD_SHORTCUTS[shortcutName]).toBe(shortcut);
|
||||
expect(CATEGORIES[shortcutCategory].settingNames.includes(shortcutName)).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user