Skip to content

Commit

Permalink
add tests for gesture private data tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
dfreedm committed May 5, 2015
1 parent 3444710 commit 842b99a
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/standard/gestures.html
Original file line number Diff line number Diff line change
Expand Up @@ -443,4 +443,4 @@
Polymer.Gestures = Gestures;

})();
</script>
</script>
19 changes: 19 additions & 0 deletions test/unit/gestures-elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,22 @@

</dom-module>

<dom-module id="x-setup">
<template>
<div id="inner" on-tap="handler" on-track="handler" on-down="handler"
on-up="handler"></div>
</template>
<script>
Polymer({
is: 'x-setup',
listeners: {
tap: 'handler',
track: 'handler',
down: 'handler',
up: 'handler'
},
handler: function(e, detail) {
}
});
</script>
</dom-module>
38 changes: 38 additions & 0 deletions test/unit/gestures.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,44 @@

});

suite('Event Setup', function() {
var outer, inner;
suiteSetup(function() {
outer = document.createElement('x-setup');
inner = outer.$.inner;
});

test('listeners', function() {
assert.equal(outer.__polymerGesturesTouchAction, 'none');
var obj = outer.__polymerGestures;
assert.equal(obj.mousedown.downup, 2, 'mousedown downup');
assert.equal(obj.mousedown.track, 1, 'mousedown track');
assert.equal(obj.mousedown.tap, 1, 'mousedown tap');
assert.equal(obj.touchstart.downup, 2, 'touchstart downup');
assert.equal(obj.touchmove.track, 1, 'touchmove track');
assert.equal(obj.touchstart.tap, 1, 'touchstart tap');
assert.equal(obj.touchend.downup, 2, 'touchend downup');
assert.equal(obj.touchend.track, 1, 'touchend track');
assert.equal(obj.touchend.tap, 1, 'touchend tap');
});

test('on-*', function() {
assert.equal(inner.__polymerGesturesTouchAction, 'none');
var obj = inner.__polymerGestures;
assert.equal(obj.mousedown.downup, 2, 'mousedown downup');
assert.equal(obj.mousedown.track, 1, 'mousedown track');
assert.equal(obj.mousedown.tap, 1, 'mousedown tap');
assert.equal(obj.touchstart.downup, 2, 'touchstart downup');
assert.equal(obj.touchmove.track, 1, 'touchmove track');
assert.equal(obj.touchstart.tap, 1, 'touchstart tap');
assert.equal(obj.touchend.downup, 2, 'touchend downup');
assert.equal(obj.touchend.track, 1, 'touchend track');
assert.equal(obj.touchend.tap, 1, 'touchend tap');
});
});

// TODO(dfreedm): Add more gesture tests!

</script>

</body>
Expand Down

0 comments on commit 842b99a

Please sign in to comment.