import { describe, it, expect } from 'vitest';
import { KEYBOARD_BINDINGS } from '../gestures/keyboard-bindings';

describe('keyboard-bindings', () => {
	it('exports a non-empty array', () => {
		expect(Array.isArray(KEYBOARD_BINDINGS)).toBe(true);
		expect(KEYBOARD_BINDINGS.length).toBeGreaterThan(0);
	});

	it('all bindings have unique IDs', () => {
		const ids = KEYBOARD_BINDINGS.map((b) => b.id);
		expect(new Set(ids).size).toBe(ids.length);
	});

	it('all bindings have a non-empty actionId', () => {
		for (const binding of KEYBOARD_BINDINGS) {
			expect(binding.actionId).toBeTruthy();
		}
	});

	it('all patterns are key kind', () => {
		for (const binding of KEYBOARD_BINDINGS) {
			expect(binding.pattern.kind).toBe('key');
		}
	});

	it('includes standard shortcuts: undo, redo, copy, paste, cut', () => {
		const actionIds = KEYBOARD_BINDINGS.map((b) => b.actionId);
		expect(actionIds).toContain('undo');
		expect(actionIds).toContain('redo');
		expect(actionIds).toContain('copy-selection');
		expect(actionIds).toContain('paste-selection');
		expect(actionIds).toContain('cut-selection');
	});

	it('has both ctrl and meta variants for copy', () => {
		const copyBindings = KEYBOARD_BINDINGS.filter((b) => b.actionId === 'copy-selection');
		expect(copyBindings.length).toBeGreaterThanOrEqual(2);
	});
});
