import { describe, it, expect } from 'vitest';
import type {
	GestureDescriptor,
	GesturePattern,
	GestureRule,
	GesturePhase,
	GestureButton,
	ModifierFlags,
	ResolvedGesture,
	GestureActionEvent,
} from '../core/gesture-rules-types';

describe('gesture-rules-types', () => {
	it('GestureDescriptor accepts a valid shape', () => {
		const descriptor: GestureDescriptor = {
			gesture: 'tap',
			target: 'node',
			source: 'mouse',
			button: 0,
			modifiers: { shift: false },
		};
		expect(descriptor.gesture).toBe('tap');
	});

	it('GesturePattern allows wildcard (omitted) fields', () => {
		const pattern: GesturePattern = { gesture: 'tap' };
		expect(pattern.target).toBeUndefined();
		expect(pattern.source).toBeUndefined();
	});

	it('GestureRule has required id, pattern, actionId', () => {
		const rule: GestureRule = {
			id: 'test-rule',
			pattern: { gesture: 'drag', target: 'node' },
			actionId: 'move-node',
			priority: 10,
		};
		expect(rule.id).toBe('test-rule');
		expect(rule.priority).toBe(10);
	});

	it('GesturePhase literal types are valid', () => {
		const phases: GesturePhase[] = ['start', 'move', 'end', 'instant'];
		expect(phases).toHaveLength(4);
	});

	it('GestureButton supports left, middle, right', () => {
		const buttons: GestureButton[] = [0, 1, 2];
		expect(buttons).toHaveLength(3);
	});

	it('ModifierFlags supports all four modifiers', () => {
		const mods: ModifierFlags = { shift: true, ctrl: false, alt: true, meta: false };
		expect(mods.shift).toBe(true);
		expect(mods.ctrl).toBe(false);
	});
});
