Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support clipboardData like dataTransfer. #585

Merged
merged 4 commits into from Jun 12, 2020

Conversation

calebmer
Copy link
Contributor

@calebmer calebmer commented May 24, 2020

To support the paste event you need the clipboardData key (which jsdom ignores). This commit extends how DOM testing library supports dataTransfer for the drop event to clipboardData.

This allows us to write tests for pasting.

Checklist:

  • Documentation added to the docs site (n/a)
  • I've prepared a PR for types targeting DefinitelyTyped (n/a)
  • Tests (edit made via GitHub, let’s see what CI says)
  • Ready to be merged

@codesandbox-ci
Copy link

codesandbox-ci bot commented May 24, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 15a7d92:

Sandbox Source
rough-browser-erxvv Configuration

@codecov
Copy link

codecov bot commented May 24, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@32dd725). Click here to learn what that means.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             master      #585   +/-   ##
==========================================
  Coverage          ?   100.00%           
==========================================
  Files             ?        24           
  Lines             ?       559           
  Branches          ?       140           
==========================================
  Hits              ?       559           
  Misses            ?         0           
  Partials          ?         0           
Impacted Files Coverage Δ
src/events.js 100.00% <100.00%> (ø)
src/query-helpers.js 100.00% <0.00%> (ø)
src/pretty-dom.js 100.00% <0.00%> (ø)
src/helpers.js 100.00% <0.00%> (ø)
src/queries/alt-text.js 100.00% <0.00%> (ø)
src/wait-for.js 100.00% <0.00%> (ø)
src/queries/placeholder-text.js 100.00% <0.00%> (ø)
src/queries/label-text.js 100.00% <0.00%> (ø)
src/screen.js 100.00% <0.00%> (ø)
... and 15 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 32dd725...15a7d92. Read the comment docs.

kentcdodds
kentcdodds previously approved these changes May 25, 2020
Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! I think I'd like to have a test for this use case specifically. Could you add one please?

@nickmccurdy
Copy link
Member

nickmccurdy commented Jun 12, 2020

I've added a basic test asserting that a POJO similar to DataTransfer can be passed to the clipboardData property of the ClipboardEvent.

Eventually as we add paste support to userEvent and merge that into this package, we can use a more realistic mock of DataTransfer. Also if anyone is interested, I made a Paste event playboard to study the DataTransfer API and make sure the test is accurate.

Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super! Thank you!

@kentcdodds kentcdodds merged commit 9592583 into testing-library:master Jun 12, 2020
@kentcdodds
Copy link
Member

@all-contributors please add @calebmer for code

@allcontributors
Copy link
Contributor

@kentcdodds

I've put up a pull request to add @calebmer! 🎉

@kentcdodds
Copy link
Member

@all-contributors please add @nickmccurdy for tests

@allcontributors
Copy link
Contributor

@kentcdodds

I've put up a pull request to add @nickmccurdy! 🎉

@kentcdodds
Copy link
Member

🎉 This PR is included in version 7.13.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants