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

Make _asyncClick easier to test, or provide a test helper #54

Open
mgiuffrida opened this issue May 4, 2016 · 0 comments
Open

Make _asyncClick easier to test, or provide a test helper #54

mgiuffrida opened this issue May 4, 2016 · 0 comments

Comments

@mgiuffrida
Copy link
Contributor

MockInteractions.pressAndReleaseKeyOn uses Polymer.Base.async to queue the keyUp event.

IronButtonState._asyncClick uses this.async to queue the click event, with a delay of 1.

This means test code has to do this:

MockInteractions.pressEnter(foo);
Polymer.dom.flush();  // flush MockInteraction's async call
foo.async(function() {
  // test foo
}, 1);  // schedule a setTimeout with a delay >= 1, so it runs after _asyncClick

The async call must have a delay greater than or equal to the one used in _asyncClick thanks to step 13. If you ever change the delay here, say from 1 to 10, my test code will fail.

(The Polymer.dom.flush() in the above is extraneous, but included for clarity.)

It would be nice if I could just do:

MockInteractions.pressEnter(foo);
Polymer.dom.flush();  // flush all the things
// test foo

or even:

MockInteractions.pressEnter(foo);
Polymer.dom.flush();  // flush MockInteraction's async call
Polymer.dom.flush();  // flush IronButtonState's async call
// test foo

so I don't have to hard-code constants and keep them up-to-date with _asyncClick.

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

No branches or pull requests

1 participant