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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix tests] use addEventListener #96

Merged
merged 5 commits into from May 8, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions .travis.yml
Expand Up @@ -17,9 +17,10 @@ addons:
- google-chrome
packages:
- google-chrome-stable
sauce_connect: true
script:
- true || xvfb-run polymer test
- xvfb-run polymer test
- >-
if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then true || polymer test -s
'default'; fi
if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then polymer test -s 'default';
fi
dist: trusty
38 changes: 22 additions & 16 deletions test/mock-interactions.html
Expand Up @@ -105,21 +105,24 @@
suite('simulating tap in ShadowRoot', function() {

test('only dispatches one tap event', function() {
button = button.$.inner;
var tapSpy = sinon.spy();
button.addEventListener('tap', tapSpy);
MockInteractions.tap(button);
button.removeEventListener('tap', tapSpy);
button.$.inner.addEventListener('tap', tapSpy);
MockInteractions.tap(button.$.inner);
expect(tapSpy.callCount).to.be.eql(1);
});

suite('with touch emulation', function() {
test('only dispatches one tap event', function() {
button = button.$.inner;
var tapSpy = sinon.spy();
Polymer.Gestures.add(button, 'tap', tapSpy);
MockInteractions.tap(button, { emulateTouch: true });
Polymer.Gestures.remove(button, 'tap', tapSpy);
// In Polymer 1.x with native ShadowDOM we need to
// patch the button with Gestures.add in order to have
// the touch emulation working.
if (!Polymer.Element && Polymer.Settings.useShadow) {
Polymer.Gestures.add(button.$.inner, 'tap', tapSpy);
} else {
button.$.inner.addEventListener('tap', tapSpy);
}
MockInteractions.tap(button.$.inner, { emulateTouch: true });
expect(tapSpy.callCount).to.be.eql(1);
});
});
Expand Down Expand Up @@ -152,23 +155,26 @@
suite('simulating down and up in ShadowRoot', function() {

test('only dispatches one tap event', function(done) {
button = button.$.inner;
var tapSpy = sinon.spy();
button.addEventListener('tap', tapSpy);
MockInteractions.downAndUp(button, function() {
button.removeEventListener('tap', tapSpy);
button.$.inner.addEventListener('tap', tapSpy);
MockInteractions.downAndUp(button.$.inner, function() {
expect(tapSpy.callCount).to.be.eql(1);
done();
});
});

suite('with touch emulation', function() {
test('only dispatches one tap event', function(done) {
button = button.$.inner;
var tapSpy = sinon.spy();
Polymer.Gestures.add(button, 'tap', tapSpy);
MockInteractions.downAndUp(button, function() {
Polymer.Gestures.remove(button, 'tap', tapSpy);
// In Polymer 1.x with native ShadowDOM we need to
// patch the button with Gestures.add in order to have
// the touch emulation working.
if (!Polymer.Element && Polymer.Settings.useShadow) {
Polymer.Gestures.add(button.$.inner, 'tap', tapSpy);
} else {
button.$.inner.addEventListener('tap', tapSpy);
}
MockInteractions.downAndUp(button.$.inner, function() {
expect(tapSpy.callCount).to.be.eql(1);
done();
}, { emulateTouch: true });
Expand Down