Fire mouse events with the correct properties #296
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
anddblClick
simulate the left mouse button. However, you can set thebutton
orbuttons
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:
Thanks for the great library! 馃槏