| 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 |
| 15 <title>paper-tabs-basic</title> |
| 16 <meta charset="utf-8"> |
| 17 <meta name="viewport" content="width=device-width, minimum-scale=1.0, initia
l-scale=1, user-scalable=yes"> |
| 18 |
| 19 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> |
| 20 <script src="../../web-component-tester/browser.js"></script> |
| 21 <script src="../../test-fixture/test-fixture-mocha.js"></script> |
| 22 |
| 23 <link rel="import" href="../paper-tabs.html"> |
| 24 <link rel="import" href="../../test-fixture/test-fixture.html"> |
| 25 |
| 26 </head> |
| 27 <body> |
| 28 |
| 29 <test-fixture id="basic"> |
| 30 <template> |
| 31 <paper-tabs> |
| 32 <paper-tab>ITEM ONE</paper-tab> |
| 33 <paper-tab>ITEM TWO</paper-tab> |
| 34 <paper-tab>ITEM THREE</paper-tab> |
| 35 </paper-tabs> |
| 36 </template> |
| 37 </test-fixture> |
| 38 |
| 39 <script> |
| 40 |
| 41 function checkSelectionBar(tabs, tab) { |
| 42 var tabRect = tab.getBoundingClientRect(); |
| 43 var rect = Polymer.dom(tabs.root).querySelector('#selectionBar').getBoun
dingClientRect(); |
| 44 assert.equal(Math.round(tabRect.left), Math.round(rect.left)); |
| 45 } |
| 46 |
| 47 suite('defaults', function() { |
| 48 |
| 49 var tabs; |
| 50 |
| 51 setup(function () { |
| 52 tabs = fixture('basic'); |
| 53 }); |
| 54 |
| 55 test('to nothing selected', function() { |
| 56 assert.equal(tabs.selected, undefined); |
| 57 }); |
| 58 |
| 59 test('no tabs have iron-selected class', function() { |
| 60 Array.prototype.forEach.call(tabs.querySelectorAll('paper-tab'), funct
ion(tab) { |
| 61 assert.isFalse(tab.classList.contains('iron-selected')); |
| 62 }); |
| 63 }); |
| 64 |
| 65 test('to false as noink', function() { |
| 66 assert.equal(tabs.noink, false); |
| 67 }); |
| 68 |
| 69 test('to false as noBar', function() { |
| 70 assert.equal(tabs.noBar, false); |
| 71 }); |
| 72 |
| 73 test('to false as noSlide', function() { |
| 74 assert.equal(tabs.noSlide, false); |
| 75 }); |
| 76 |
| 77 test('to false as scrollable', function() { |
| 78 assert.equal(tabs.scrollable, false); |
| 79 }); |
| 80 |
| 81 test('to false as disableDrag', function() { |
| 82 assert.equal(tabs.disableDrag, false); |
| 83 }); |
| 84 |
| 85 test('to false as hideScrollButtons', function() { |
| 86 assert.equal(tabs.hideScrollButtons, false); |
| 87 }); |
| 88 |
| 89 test('to false as alignBottom', function() { |
| 90 assert.equal(tabs.alignBottom, false); |
| 91 }); |
| 92 |
| 93 test('has role tablist', function() { |
| 94 assert.equal(tabs.getAttribute('role'), 'tablist'); |
| 95 }); |
| 96 |
| 97 }); |
| 98 |
| 99 suite('set the selected attribute', function() { |
| 100 |
| 101 var tabs, index = 0; |
| 102 |
| 103 setup(function () { |
| 104 tabs = fixture('basic'); |
| 105 tabs.selected = index; |
| 106 }); |
| 107 |
| 108 test('selected value', function() { |
| 109 assert.equal(tabs.selected, index); |
| 110 }); |
| 111 |
| 112 test('selected tab has iron-selected class', function() { |
| 113 var tab = tabs.querySelectorAll('paper-tab')[index]; |
| 114 assert.isTrue(tab.classList.contains('iron-selected')); |
| 115 }); |
| 116 |
| 117 test('selected tab has selection bar position at the bottom of the tab',
function(done) { |
| 118 setTimeout(function() { |
| 119 checkSelectionBar(tabs, tabs.querySelectorAll('paper-tab')[index]); |
| 120 done(); |
| 121 }, 1000); |
| 122 }); |
| 123 |
| 124 }); |
| 125 |
| 126 suite('select tab via click', function() { |
| 127 |
| 128 var tabs, index = 1; |
| 129 |
| 130 setup(function () { |
| 131 tabs = fixture('basic'); |
| 132 var tab = tabs.querySelectorAll('paper-tab')[index]; |
| 133 tab.dispatchEvent(new CustomEvent('click', {bubbles: true})); |
| 134 }); |
| 135 |
| 136 test('selected value', function() { |
| 137 assert.equal(tabs.selected, index); |
| 138 }); |
| 139 |
| 140 test('selected tab has iron-selected class', function() { |
| 141 var tab = tabs.querySelectorAll('paper-tab')[index]; |
| 142 assert.isTrue(tab.classList.contains('iron-selected')); |
| 143 }); |
| 144 |
| 145 test('selected tab has selection bar position at the bottom of the tab',
function(done) { |
| 146 setTimeout(function() { |
| 147 checkSelectionBar(tabs, tabs.querySelectorAll('paper-tab')[index]); |
| 148 done(); |
| 149 }, 1000); |
| 150 }); |
| 151 |
| 152 }); |
| 153 |
| 154 </script> |
| 155 |
| 156 </body> |
| 157 </html> |
| OLD | NEW |