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>iron-pages-attr-for-selected</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="../iron-pages.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 <iron-pages attr-for-selected="name" selected="page0"> |
| 32 <div name="page0">Page 0</div> |
| 33 <div name="page1">Page 1</div> |
| 34 <div name="page2">Page 2</div> |
| 35 <div name="page3">Page 3</div> |
| 36 </iron-pages> |
| 37 </template> |
| 38 </test-fixture> |
| 39 |
| 40 <script> |
| 41 |
| 42 suite('basic', function() { |
| 43 var pages; |
| 44 |
| 45 suite('honor the selected attribute', function() { |
| 46 setup(function () { |
| 47 pages = fixture('basic'); |
| 48 }); |
| 49 |
| 50 test('selected value', function() { |
| 51 assert.equal(pages.selected, 'page0'); |
| 52 }); |
| 53 |
| 54 test('selected item', function() { |
| 55 assert.equal(pages.selectedItem, pages.items[0]); |
| 56 }); |
| 57 |
| 58 test('selected item is display:block and all others are display:none',
function() { |
| 59 pages.items.forEach(function(p) { |
| 60 assert.equal(getComputedStyle(p).display, p == pages.selectedItem
? 'block' : 'none'); |
| 61 }); |
| 62 }); |
| 63 }); |
| 64 |
| 65 suite('set selected attribute', function() { |
| 66 setup(function () { |
| 67 pages = fixture('basic'); |
| 68 pages.selected = 'page2'; |
| 69 }); |
| 70 |
| 71 test('selected value', function() { |
| 72 assert.equal(pages.selected, 'page2'); |
| 73 }); |
| 74 |
| 75 test('selected item', function() { |
| 76 assert.equal(pages.selectedItem, pages.items[2]); |
| 77 }); |
| 78 |
| 79 test('selected item is display:block and all others are display:none',
function() { |
| 80 pages.items.forEach(function(p) { |
| 81 assert.equal(getComputedStyle(p).display, p == pages.selectedItem
? 'block' : 'none'); |
| 82 }); |
| 83 }); |
| 84 }); |
| 85 |
| 86 }); |
| 87 |
| 88 </script> |
| 89 |
| 90 </body> |
| 91 </html> |
OLD | NEW |