user-event icon indicating copy to clipboard operation
user-event copied to clipboard

clipboardData DataTransferStub.getData should convert format string argument to ASCII lowercase

Open joshunger opened this issue 2 years ago • 0 comments

Reproduction example

https://codesandbox.io/s/happy-dust-ijlfer?file=/src/App.js

Prerequisites

  1. Render
<input
  onPaste={(e) => {
    const text = e.clipboardData.getData('Text')
    setVal(text)
  }}
  value={val}
/>
  1. Paste clipboard data.

Expected behavior

If I call .paste('12345') then DataTransferStub.getData('Text') should return the pasted value of 12345. The format string Text should be converted to lowercase before searching for items. See codesandbox.

Actual behavior

The DataTransferStub.getData('Text') returns ''.

User-event version

14.4.3

Environment

Testing Library framework:

JS framework:

Test environment:

DOM implementation:

Additional context

I found this in the spec https://html.spec.whatwg.org/multipage/dnd.html

Let format be the first argument, converted to ASCII lowercase.

Turns out our production code is using Text 🤷

joshunger avatar May 17 '23 15:05 joshunger