import { describe, expect, it } from 'vitest' import { isDictatedInput } from './use-keyboard-dictation' describe('isDictatedInput', () => { it('takes words or phrases written without a key press as dictation', () => { expect(isDictatedInput({ inputType: 'insertText', data: 'Yogur', msSinceKeydown: 5000 })).toBe( true, ) expect( isDictatedInput({ inputType: 'insertReplacementText', data: null, msSinceKeydown: 5000 }), ).toBe(true) }) it('does not take typing as dictation', () => { expect(isDictatedInput({ inputType: 'insertText', data: 'Yogur', msSinceKeydown: 10 })).toBe( false, ) expect(isDictatedInput({ inputType: 'insertText', data: 'y', msSinceKeydown: 5000 })).toBe( false, ) }) it('never takes pastes, drops or deletions as dictation', () => { for (const inputType of ['insertFromPaste', 'insertFromDrop', 'deleteContentBackward']) { expect(isDictatedInput({ inputType, data: 'leche y pan', msSinceKeydown: 5000 })).toBe(false) } }) })