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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fire mouse events with the correct properties #296

Merged
merged 2 commits into from May 22, 2020

Conversation

devongovett
Copy link
Contributor

@devongovett devongovett commented May 22, 2020

What:

This ensures that all mouse events are fired with the correct values for the button, buttons, and detail properties. This emulates what a browser would do, and is important for code that relies on this behavior. In addition, it should be possible to pass custom properties through to all events (e.g. altKey, and screen positions).

Why:

Tests should simulate how a browser fires them as closely as possible.

How:

Looked at the spec for each property and emulated the required behavior. Also tested in a real application that relies on some of them.

By default, click and dblClick simulate the left mouse button. However, you can set the button or buttons property when firing the event to override this. user-event will handle mapping the one that's set to the alternative one if unset, so it's consistent no matter which is specified.

In addition, the detail property is set according to the number of clicks that have occurred.

Checklist:

  • Documentation (N/A)
  • Tests
  • Typings
  • Ready to be merged

Thanks for the great library! 馃槏

@codecov
Copy link

codecov bot commented May 22, 2020

Codecov Report

Merging #296 into master will increase coverage by 0.13%.
The diff coverage is 97.05%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #296      +/-   ##
==========================================
+ Coverage   98.76%   98.90%   +0.13%     
==========================================
  Files           1        1              
  Lines         162      182      +20     
  Branches       46       55       +9     
==========================================
+ Hits          160      180      +20     
  Misses          2        2              
Impacted Files Coverage 螖
src/index.js 98.90% <97.05%> (+0.13%) 猬嗭笍

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 bfbe92c...1f41ad3. Read the comment docs.

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.

This is very thorough! Thanks a lot 馃憦

@kentcdodds kentcdodds merged commit 6239c3a into testing-library:master May 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants