// @vitest-environment happy-dom import { describe, it, expect } from 'vitest' import { arrowNavAllowed, hasText, isTextEntry } from '../src/utils/textEntry.js' describe('textEntry helpers', () => { it('navigates when the target is not a text field', () => { expect(arrowNavAllowed(document.createElement('div'))).toBe(true) expect(arrowNavAllowed(null)).toBe(true) }) it('navigates when a focused tag input is empty', () => { const input = document.createElement('input') input.value = '' expect(arrowNavAllowed(input)).toBe(true) }) it('does NOT navigate when the input has text (caret moves instead)', () => { const input = document.createElement('input') input.value = 'naruto' expect(arrowNavAllowed(input)).toBe(false) }) it('isTextEntry / hasText recognise inputs and textareas', () => { const ta = document.createElement('textarea') ta.value = 'x' expect(isTextEntry(ta)).toBe(true) expect(hasText(ta)).toBe(true) expect(isTextEntry(document.createElement('div'))).toBe(false) }) })