diff --git a/test/unit/gestures-elements.html b/test/unit/gestures-elements.html index ccf03f36ea..534b4edfbf 100644 --- a/test/unit/gestures-elements.html +++ b/test/unit/gestures-elements.html @@ -227,3 +227,19 @@ customElements.define(XNativeLabel.is, XNativeLabel); + + + + + \ No newline at end of file diff --git a/test/unit/gestures.html b/test/unit/gestures.html index 465abf2fe6..30866d06fa 100644 --- a/test/unit/gestures.html +++ b/test/unit/gestures.html @@ -560,30 +560,59 @@ Polymer.Gestures.remove(window, 'tap', increment); }); - test('native label click', function() { - let el = document.createElement('x-native-label'); - document.body.appendChild(el); - let target = el.$.label; - // simulate the event sequence of a touch on the screen - let touches = [{ - clientX: 0, - clientY: 0, - identifier: 1, - // target is set to the element with `addEventListener`, which is `target` - target - }]; - let touchstart = new CustomEvent('touchstart', {bubbles: true, composed: true}); - touchstart.changedTouches = touchstart.touches = touches; - target.dispatchEvent(touchstart); - let touchend = new CustomEvent('touchend', {bubbles: true, composed: true}); - touchend.touches = touchend.changedTouches = touches; - target.dispatchEvent(touchend); - // simulate a mouse click on the label - let click = new MouseEvent('click', {bubbles: true, composed: true}); - target.dispatchEvent(click); - // check that the mouse click on the label will activate the checkbox - assert.equal(el.$.check.checked, true, 'checkbox should be checked'); - document.body.removeChild(el); + suite('native label click', function() { + + test('native label click', function() { + let el = document.createElement('x-native-label'); + document.body.appendChild(el); + let target = el.$.label; + // simulate the event sequence of a touch on the screen + let touches = [{ + clientX: 0, + clientY: 0, + identifier: 1, + // target is set to the element with `addEventListener`, which is `target` + target + }]; + let touchstart = new CustomEvent('touchstart', {bubbles: true, composed: true}); + touchstart.changedTouches = touchstart.touches = touches; + target.dispatchEvent(touchstart); + let touchend = new CustomEvent('touchend', {bubbles: true, composed: true}); + touchend.touches = touchend.changedTouches = touches; + target.dispatchEvent(touchend); + // simulate a mouse click on the label + let click = new MouseEvent('click', {bubbles: true, composed: true}); + target.dispatchEvent(click); + // check that the mouse click on the label will activate the checkbox + assert.equal(el.$.check.checked, true, 'checkbox should be checked'); + document.body.removeChild(el); + }); + }); + + test('label click with nested element', function() { + let el = document.createElement('x-native-label-nested'); + document.body.appendChild(el); + let target = el.$.label; + // simulate the event sequence of a touch on the screen + let touches = [{ + clientX: 0, + clientY: 0, + identifier: 1, + // target is set to the element with `addEventListener`, which is `target` + target + }]; + let touchstart = new CustomEvent('touchstart', {bubbles: true, composed: true}); + touchstart.changedTouches = touchstart.touches = touches; + target.dispatchEvent(touchstart); + let touchend = new CustomEvent('touchend', {bubbles: true, composed: true}); + touchend.touches = touchend.changedTouches = touches; + target.dispatchEvent(touchend); + // simulate a mouse click on the label + let click = new MouseEvent('click', {bubbles: true, composed: true}); + target.dispatchEvent(click); + // check that the mouse click on the label will activate the checkbox + assert.equal(el.$.check.checked, true, 'checkbox should be checked'); + document.body.removeChild(el); }); });