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

Expose click() in MockInteractions #93

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

NovapaX
Copy link

@NovapaX NovapaX commented Feb 22, 2018

How else are we supposed to test a click on a certain xy-location...

How else are we supposed to test a click on a certain xy-location...
@valdrinkoshi
Copy link
Member

Hi, a click event would need to generate also up and down event before getting fired. This is done by tap - see implementation.

If you want to set a different xy instead of the middle of the node, we could just handle a new property in the options object passed to tap, e.g.

MockInteractions.tap(node, {
  xy: MockInteractions.topLeftOfNode(node)
});

const bounds = node.getBoundingClientRect();
MockInteractions.tap(node, {
  xy: { x: bounds.left + 5, y: bounds.top + 10 }
});

Mind opening an issue for this?

Copy link
Member

@valdrinkoshi valdrinkoshi left a comment

Choose a reason for hiding this comment

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

Can you add a description to this PR? e.g.
"Fixes #94 by ...."

Regarding the fix, I would not expose click but rather enhance the options for tap,e.g.

  function tap(node, options) {
    // Respect nodes that are disabled in the UI.
    if (window.getComputedStyle(node)['pointer-events'] === 'none')
      return;

    var xy = (options || {}).xy || middleOfNode(node);

And also add unit tests

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.

3 participants