3
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
4
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7
Code distributed by Google as part of the polymer project is also
8
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
12
<meta charset="UTF-8">
13
<title>paper-radio-button basic tests</title>
14
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
16
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
17
<script src="../../web-component-tester/browser.js"></script>
18
<script src="../../test-fixture/test-fixture-mocha.js"></script>
19
<script src="../../iron-test-helpers/mock-interactions.js"></script>
21
<link rel="import" href="../../test-fixture/test-fixture.html">
22
<link rel="import" href="../paper-radio-button.html">
27
<test-fixture id="NoLabel">
29
<paper-radio-button id="radio1"></paper-radio-button>
33
<test-fixture id="WithLabel">
35
<paper-radio-button id="radio2">Batman</paper-radio-button>
39
<test-fixture id="AriaLabel">
41
<paper-radio-button aria-label="Batman">Robin</paper-radio-button>
46
suite('defaults', function() {
50
r1 = fixture('NoLabel');
53
test('check button via click', function(done) {
54
r1.addEventListener('click', function() {
55
assert.isTrue(r1.getAttribute('aria-checked') == 'true');
56
assert.isTrue(r1.checked);
59
MockInteractions.tap(r1);
62
test('toggle button via click', function(done) {
64
r1.addEventListener('click', function() {
65
assert.isFalse(r1.getAttribute('aria-checked') == 'true');
66
assert.isFalse(r1.checked);
69
MockInteractions.tap(r1);
72
test('disabled button cannot be clicked', function(done) {
75
MockInteractions.tap(r1);
77
setTimeout(function() {
78
assert.isTrue(r1.getAttribute('aria-checked') == 'true');
79
assert.isTrue(r1.checked);
85
suite('a11y', function() {
90
r1 = fixture('NoLabel');
91
r2 = fixture('WithLabel');
94
test('has aria role "radio"', function() {
95
assert.isTrue(r1.getAttribute('role') == 'radio');
96
assert.isTrue(r2.getAttribute('role') == 'radio');
99
test('button with no label has no aria label', function() {
100
assert.isTrue(!r1.getAttribute('aria-label'));
103
test('button respects the user set aria-label', function() {
104
var c = fixture('AriaLabel');
105
assert.isTrue(c.getAttribute('aria-label') == "Batman");
108
a11ySuite('NoLabel');
109
a11ySuite('WithLabel');
110
a11ySuite('AriaLabel');