summaryrefslogtreecommitdiff
path: root/packages/cli/src/config/keyBindings.test.ts
diff options
context:
space:
mode:
authorLee Won Jun <[email protected]>2025-08-09 16:03:17 +0900
committerGitHub <[email protected]>2025-08-09 07:03:17 +0000
commitb8084ba8158b89facd49fd78a51abb80b1db54da (patch)
tree5fd41e255b5118d53798c29d9fad95478a1ed582 /packages/cli/src/config/keyBindings.test.ts
parent6487cc16895976ef6c983f8beca08a64addb6688 (diff)
Centralize Key Binding Logic and Refactor (Reopen) (#5356)
Co-authored-by: Lee-WonJun <[email protected]>
Diffstat (limited to 'packages/cli/src/config/keyBindings.test.ts')
-rw-r--r--packages/cli/src/config/keyBindings.test.ts62
1 files changed, 62 insertions, 0 deletions
diff --git a/packages/cli/src/config/keyBindings.test.ts b/packages/cli/src/config/keyBindings.test.ts
new file mode 100644
index 00000000..2e89e421
--- /dev/null
+++ b/packages/cli/src/config/keyBindings.test.ts
@@ -0,0 +1,62 @@
+/**
+ * @license
+ * Copyright 2025 Google LLC
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+import { describe, it, expect } from 'vitest';
+import {
+ Command,
+ KeyBindingConfig,
+ defaultKeyBindings,
+} from './keyBindings.js';
+
+describe('keyBindings config', () => {
+ describe('defaultKeyBindings', () => {
+ it('should have bindings for all commands', () => {
+ const commands = Object.values(Command);
+
+ for (const command of commands) {
+ expect(defaultKeyBindings[command]).toBeDefined();
+ expect(Array.isArray(defaultKeyBindings[command])).toBe(true);
+ }
+ });
+
+ it('should have valid key binding structures', () => {
+ for (const [_, bindings] of Object.entries(defaultKeyBindings)) {
+ for (const binding of bindings) {
+ // Each binding should have either key or sequence, but not both
+ const hasKey = binding.key !== undefined;
+ const hasSequence = binding.sequence !== undefined;
+
+ expect(hasKey || hasSequence).toBe(true);
+ expect(hasKey && hasSequence).toBe(false);
+
+ // Modifier properties should be boolean or undefined
+ if (binding.ctrl !== undefined) {
+ expect(typeof binding.ctrl).toBe('boolean');
+ }
+ if (binding.shift !== undefined) {
+ expect(typeof binding.shift).toBe('boolean');
+ }
+ if (binding.command !== undefined) {
+ expect(typeof binding.command).toBe('boolean');
+ }
+ if (binding.paste !== undefined) {
+ expect(typeof binding.paste).toBe('boolean');
+ }
+ }
+ }
+ });
+
+ it('should export all required types', () => {
+ // Basic type checks
+ expect(typeof Command.HOME).toBe('string');
+ expect(typeof Command.END).toBe('string');
+
+ // Config should be readonly
+ const config: KeyBindingConfig = defaultKeyBindings;
+ expect(config[Command.HOME]).toBeDefined();
+ });
+ });
+});