import { describe, it, expect } from 'vitest';
import { isTypingTarget } from './readerKeys';

function el(tag: string, contentEditable = false): HTMLElement {
    const node = document.createElement(tag);
    if (contentEditable) node.setAttribute('contenteditable', 'true');
    return node;
}

describe('isTypingTarget', () => {
    it('is true for text-entry and native-key elements', () => {
        expect(isTypingTarget(el('input'))).toBe(true);
        expect(isTypingTarget(el('textarea'))).toBe(true);
        expect(isTypingTarget(el('select'))).toBe(true);
        expect(isTypingTarget(el('div', true))).toBe(true);
    });

    it('is false for ordinary elements and null', () => {
        expect(isTypingTarget(el('div'))).toBe(false);
        expect(isTypingTarget(el('button'))).toBe(false);
        expect(isTypingTarget(null)).toBe(false);
    });
});
