diff --git a/src/__tests__/type-modifiers.js b/src/__tests__/type-modifiers.js index f398ea99..be1b3dee 100644 --- a/src/__tests__/type-modifiers.js +++ b/src/__tests__/type-modifiers.js @@ -117,6 +117,14 @@ test('{backspace} deletes the selected range', async () => { `) }) +test('{backspace} on an input type that does not support selection ranges', async () => { + const {element} = setup() + // note: you cannot even call setSelectionRange on these kinds of elements... + await userEvent.type(element, '{backspace}') + // removed "m" + expect(element).toHaveValue('yo@example.co') +}) + test('{alt}a{/alt}', async () => { const {element: input, getEventCalls} = setup() diff --git a/src/__tests__/type.js b/src/__tests__/type.js index 8735dfee..8b57efe5 100644 --- a/src/__tests__/type.js +++ b/src/__tests__/type.js @@ -521,3 +521,53 @@ test('ignored {backspace} in controlled input', async () => { keyup: 4 (52) `) }) + +// https://github.com/testing-library/user-event/issues/321 +test('typing in a textarea with existing text', async () => { + const {element, getEventCalls} = setup(