4
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
5
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
6
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
7
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
8
Code distributed by Google as part of the polymer project is also
9
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
13
<meta charset="UTF-8">
14
<title>iron-label event tests</title>
15
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
16
<script src="../../web-component-tester/browser.js"></script>
17
<script src="../../test-fixture/test-fixture-mocha.js"></script>
18
<link rel="import" href="../../test-fixture/test-fixture.html">
19
<link rel="import" href="../../iron-test-helpers/iron-test-helpers.html">
21
<link rel="import" href="../iron-label.html">
25
<test-fixture id="Inside">
27
<iron-label id="inside">
28
TEXT <input type="checkbox">
33
<test-fixture id="Outside">
35
<iron-label id="outside" for="outside-checkbox">
38
<input id="outside-checkbox" type="checkbox">
42
<test-fixture id="Reordered">
44
<iron-label id="reordered">
46
<input iron-label-target type="checkbox">
52
suite('event handling', function() {
54
suite('target inside', function() {
57
inside = fixture('Inside');
58
target = inside.firstElementChild;
61
test('target has aria-labelledby', function() {
62
var label = target.getAttribute('aria-labelledby');
63
assert.equal(label, 'inside');
66
test('tap on label goes to the target', function() {
68
Polymer.Gestures.add(target, 'tap', function() {
71
MockInteractions.tap(inside);
72
assert.equal(count, 1);
75
test('tap on target does not recurse', function() {
77
Polymer.Gestures.add(target, 'tap', function() {
80
MockInteractions.tap(target);
81
assert.equal(count, 1);
84
test('tap on label will "activate" target', function() {
85
target.checked = false;
86
MockInteractions.tap(inside);
87
assert.equal(target.checked, true);
91
suite('target outside', function() {
94
var temp = fixture('Outside');
99
test('target has aria-labelledby', function() {
100
var label = target.getAttribute('aria-labelledby');
101
assert.equal(label, 'outside');
104
test('tap on label goes to the target', function() {
106
Polymer.Gestures.add(target, 'tap', function() {
109
MockInteractions.tap(outside);
110
assert.equal(count, 1);
113
test('tap on label will "activate" target', function() {
114
target.checked = false;
115
MockInteractions.tap(outside);
116
assert.equal(target.checked, true);
120
suite('target by reordered', function() {
121
var reordered, target;
123
reordered = fixture('Reordered');
125
Polymer.dom(reordered).querySelector('[iron-label-target]');
128
test('target has aria-labelledby', function() {
129
var label = target.getAttribute('aria-labelledby');
130
assert.equal(label, 'reordered');
133
test('tap on label goes to the target', function() {
135
Polymer.Gestures.add(target, 'tap', function() {
138
MockInteractions.tap(reordered);
139
assert.equal(count, 1);
142
test('tap on label will "activate" target', function() {
143
target.checked = false;
144
MockInteractions.tap(reordered);
145
assert.equal(target.checked, true);