OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <!-- |
| 3 @license |
| 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.g
ithub.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/CONTRI
BUTORS.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/PATEN
TS.txt |
| 10 --> |
| 11 |
| 12 <html> |
| 13 <head> |
| 14 <title>paper-checked-element-behavior</title> |
| 15 |
| 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> |
| 20 |
| 21 <link rel="import" href="../../polymer/polymer.html"> |
| 22 <link rel="import" href="../../test-fixture/test-fixture.html"> |
| 23 <link rel="import" href="../paper-checked-element-behavior.html"> |
| 24 </head> |
| 25 <body> |
| 26 |
| 27 <dom-module id="test-checked"> |
| 28 <template> |
| 29 </template> |
| 30 <script> |
| 31 HTMLImports.whenReady(function() { |
| 32 Polymer({ |
| 33 is: 'test-checked', |
| 34 behaviors: [ |
| 35 Polymer.PaperCheckedElementBehavior |
| 36 ] |
| 37 }); |
| 38 }); |
| 39 </script> |
| 40 </dom-module> |
| 41 |
| 42 <test-fixture id="basic"> |
| 43 <template> |
| 44 <test-checked></test-checked> |
| 45 </template> |
| 46 </test-fixture> |
| 47 |
| 48 <script> |
| 49 suite('PaperCheckedElementBehavior', function() { |
| 50 var checked; |
| 51 |
| 52 setup(function() { |
| 53 checked = fixture('basic'); |
| 54 }); |
| 55 |
| 56 test('element checked when tapped to check', function() { |
| 57 MockInteractions.tap(checked); |
| 58 assert.isTrue(checked.checked); |
| 59 }); |
| 60 |
| 61 test('element checked when active', function() { |
| 62 checked.active = true; |
| 63 assert.isTrue(checked.checked); |
| 64 }); |
| 65 |
| 66 test('element not checked when disabled and made active', function() { |
| 67 checked.disabled = true; |
| 68 checked.active = true; |
| 69 assert.isFalse(checked.checked); |
| 70 }); |
| 71 |
| 72 test('element not checked when disabled and tapped', function() { |
| 73 checked.disabled = true; |
| 74 MockInteractions.tap(checked); |
| 75 assert.isFalse(checked.checked); |
| 76 }); |
| 77 |
| 78 test('element ripple has checked attribute when element tapped to check',
function() { |
| 79 MockInteractions.tap(checked); |
| 80 assert.isTrue(checked.hasRipple()); |
| 81 assert.isTrue(checked.getRipple().hasAttribute('checked')); |
| 82 }); |
| 83 |
| 84 test('element ripple does not have checked attribute when element tapped t
o uncheck', function() { |
| 85 MockInteractions.tap(checked); |
| 86 MockInteractions.tap(checked); |
| 87 assert.isFalse(checked.getRipple().hasAttribute('checked')); |
| 88 }); |
| 89 |
| 90 }); |
| 91 </script> |
| 92 |
| 93 </body> |
| 94 </html> |
OLD | NEW |