1<!doctype html> 2<!-- 3@license 4Copyright (c) 2015 The Polymer Project Authors. All rights reserved. 5This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 6The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 7The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 8Code distributed by Google as part of the polymer project is also 9subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 10--> 11 12<html> 13 <head> 14 15 <title>iron-pages-basic</title> 16 <meta charset="utf-8"> 17 <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes"> 18 19 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> 20 <script src="../../web-component-tester/browser.js"></script> 21 <link rel="import" href="../iron-pages.html"> 22 23 </head> 24 <body> 25 26 <test-fixture id="basic"> 27 <template> 28 <iron-pages> 29 <div id="page0">Page 0</div> 30 <div id="page1">Page 1</div> 31 <div id="page2">Page 2</div> 32 <div id="page3">Page 3</div> 33 </iron-pages> 34 </template> 35 </test-fixture> 36 37 <script> 38 39 suite('basic', function() { 40 var pages; 41 42 suite('defaults', function() { 43 setup(function () { 44 pages = fixture('basic'); 45 }); 46 47 test('to nothing selected', function() { 48 assert.equal(pages.selected, undefined); 49 }); 50 51 test('null activateEvent', function() { 52 // `activateEvent` is not a useful feature for iron-pages and it can interfere 53 // with ux; ensure iron-pages has cleared any default `activateEvent` 54 assert.equal(pages.activateEvent, null); 55 }); 56 57 test('to iron-selected as selectedClass', function() { 58 assert.equal(pages.selectedClass, 'iron-selected'); 59 }); 60 61 test('as many items as children', function() { 62 assert.equal(pages.items.length, 4); 63 }); 64 65 test('all pages are display:none', function() { 66 pages.items.forEach(function(p) { 67 assert.equal(getComputedStyle(p).display, 'none'); 68 }); 69 }); 70 }); 71 72 suite('set the selected attribute', function() { 73 setup(function () { 74 pages = fixture('basic'); 75 pages.selected = 0; 76 }); 77 78 test('selected value', function() { 79 assert.equal(pages.selected, '0'); 80 }); 81 82 test('selected item', function() { 83 assert.equal(pages.selectedItem, pages.items[0]); 84 }); 85 86 test('selected item is display:block and all others are display:none', function() { 87 pages.items.forEach(function(p) { 88 assert.equal(getComputedStyle(p).display, p == pages.selectedItem ? 'block' : 'none'); 89 }); 90 }); 91 }); 92 93 }); 94 95 </script> 96 97 </body> 98</html> 99