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

Fix MockInteractions.track to provide correct step values #60

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mock-interactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@
*/
function move(node, fromXY, toXY, steps) {
steps = steps || 5;
var dx = Math.round((fromXY.x - toXY.x) / steps);
var dy = Math.round((fromXY.y - toXY.y) / steps);
var dx = Math.round((toXY.x - fromXY.x) / steps);
var dy = Math.round((toXY.y - fromXY.y) / steps);
var xy = {
x: fromXY.x,
y: fromXY.y
Expand Down
22 changes: 17 additions & 5 deletions test/mock-interactions.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,8 @@
button = fixture('TrivialButton');
});

teardown(function(done) {
// TODO(cdata): Remove when polymer/polymer#3540 is resolved
window.setTimeout(function() {
done();
}, 2500);
teardown(function() {
Polymer.Gestures.resetMouseCanceller();
});

suite('simulating tap', function() {
Expand Down Expand Up @@ -86,6 +83,21 @@
});
});
});

suite('simulating track', function() {
test('dispatches events with correct steps', function() {
var spy = sinon.spy();
button.handleTrack = spy;
button.listen(button, 'track', 'handleTrack');
MockInteractions.track(button, 50, 50, 5);

var steps = [10, 20, 30, 40, 50, 50];
for (var i = 0, l = steps.length; i < l; i++) {
expect(spy.getCall(i).args[0].detail.dx).to.be.eql(steps[i]);
expect(spy.getCall(i).args[0].detail.dy).to.be.eql(steps[i]);
}
});
});
});

</script>
Expand Down