import { describe, it, expect } from 'vitest';
import { CanvasEventType, EVENT_TYPE_INFO } from '../core/event-types';

describe('event-types enums', () => {
	describe('CanvasEventType', () => {
		it('has all node event types', () => {
			expect(CanvasEventType.NodeClick).toBe('node:click');
			expect(CanvasEventType.NodeDoubleClick).toBe('node:double-click');
			expect(CanvasEventType.NodeTripleClick).toBe('node:triple-click');
			expect(CanvasEventType.NodeRightClick).toBe('node:right-click');
			expect(CanvasEventType.NodeLongPress).toBe('node:long-press');
		});

		it('has all edge event types', () => {
			expect(CanvasEventType.EdgeClick).toBe('edge:click');
			expect(CanvasEventType.EdgeDoubleClick).toBe('edge:double-click');
			expect(CanvasEventType.EdgeRightClick).toBe('edge:right-click');
		});

		it('has all background event types', () => {
			expect(CanvasEventType.BackgroundClick).toBe('background:click');
			expect(CanvasEventType.BackgroundDoubleClick).toBe('background:double-click');
			expect(CanvasEventType.BackgroundRightClick).toBe('background:right-click');
			expect(CanvasEventType.BackgroundLongPress).toBe('background:long-press');
		});

		it('has 12 total event types', () => {
			const numericKeys = Object.keys(CanvasEventType).filter((k) => isNaN(Number(k)));
			expect(numericKeys.length).toBe(12);
		});
	});

	describe('EVENT_TYPE_INFO', () => {
		it('covers all CanvasEventType values', () => {
			const allTypes = Object.values(CanvasEventType).filter((v) => typeof v === 'string');
			for (const type of allTypes) {
				expect(EVENT_TYPE_INFO[type as CanvasEventType]).toBeDefined();
			}
		});

		it('all entries have label and description', () => {
			for (const info of Object.values(EVENT_TYPE_INFO)) {
				expect(info.label).toBeTruthy();
				expect(info.description).toBeTruthy();
			}
		});

		it('categories are valid', () => {
			const validCategories = new Set(['node', 'edge', 'background']);
			for (const info of Object.values(EVENT_TYPE_INFO)) {
				expect(validCategories.has(info.category)).toBe(true);
			}
		});

		it('node events have node category', () => {
			expect(EVENT_TYPE_INFO[CanvasEventType.NodeClick].category).toBe('node');
		});

		it('edge events have edge category', () => {
			expect(EVENT_TYPE_INFO[CanvasEventType.EdgeClick].category).toBe('edge');
		});

		it('background events have background category', () => {
			expect(EVENT_TYPE_INFO[CanvasEventType.BackgroundClick].category).toBe('background');
		});
	});
});
