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
14
<title>paper-button-behavior</title>
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="../../polymer/polymer.html">
22
<link rel="import" href="../../test-fixture/test-fixture.html">
23
<link rel="import" href="test-button.html">
27
<test-fixture id="basic">
29
<test-button></test-button>
34
suite('basic', function() {
38
button = fixture('basic');
41
test('normal (no states)', function() {
42
assert.equal(button.elevation, 1);
45
test('set disabled property', function() {
46
button.disabled = true;
47
assert.equal(button.elevation, 0);
50
test('pressed and released', function() {
51
MockInteractions.down(button);
52
assert.equal(button.elevation, 4);
53
MockInteractions.up(button);
54
assert.equal(button.elevation, 1);
55
assert.ok(button.hasRipple());
58
suite('a button with toggles', function() {
60
button.toggles = true;
63
test('activated by tap', function(done) {
64
MockInteractions.downAndUp(button, function() {
66
assert.equal(button.elevation, 4);
67
assert.ok(button.hasRipple());
76
test('receives focused', function() {
77
MockInteractions.focus(button);
78
assert.equal(button.elevation, 3);
79
assert.ok(button.hasRipple());
82
test('space key', function(done) {
83
const SPACE_KEY_CODE = 32;
85
MockInteractions.focus(button);
87
assert.ok(button.hasRipple());
89
ripple = button.getRipple();
90
MockInteractions.keyDownOn(button, SPACE_KEY_CODE);
92
assert.equal(ripple.ripples.length, 1);
94
MockInteractions.keyDownOn(button, SPACE_KEY_CODE);
96
assert.equal(ripple.ripples.length, 1);
98
MockInteractions.keyUpOn(button, SPACE_KEY_CODE);
100
var transitionEndCalled = false;
101
ripple.addEventListener('transitionend', function() {
102
if (!transitionEndCalled) {
103
transitionEndCalled = true;
104
assert.equal(ripple.ripples.length, 0);