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 |
| 6 The complete set of authors may be found at http://polymer.github.io/AUTHORS |
| 7 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS |
| 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 |
| 10 --> |
| 11 <html> |
| 12 <head> |
| 13 <meta charset="UTF-8"> |
| 14 <title>iron-list test</title> |
| 15 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-
scale=1.0"> |
| 16 |
| 17 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> |
| 18 <script src="../../web-component-tester/browser.js"></script> |
| 19 <script src="../../test-fixture/test-fixture-mocha.js"></script> |
| 20 <script src="../../iron-test-helpers/mock-interactions.js"></script> |
| 21 |
| 22 <link rel="import" href="../../test-fixture/test-fixture.html"> |
| 23 <link rel="import" href="../../paper-styles/paper-styles.html"> |
| 24 <link rel="import" href="helpers.html"> |
| 25 <link rel="import" href="x-list.html"> |
| 26 |
| 27 </head> |
| 28 <body> |
| 29 |
| 30 <test-fixture id="trivialList"> |
| 31 <template> |
| 32 <x-list item-height="0" pre></x-list> |
| 33 </template> |
| 34 </test-fixture> |
| 35 |
| 36 <script> |
| 37 |
| 38 suite('Dynamic item size', function() { |
| 39 var list, container; |
| 40 |
| 41 setup(function() { |
| 42 container = fixture('trivialList'); |
| 43 list = container.list; |
| 44 }); |
| 45 |
| 46 test('update size using item index', function(done) { |
| 47 list.items = buildDataSet(100); |
| 48 |
| 49 flush(function() { |
| 50 var firstItem = getFirstItemFromList(list); |
| 51 var initHeight = firstItem.offsetHeight; |
| 52 |
| 53 list.set('items.0.index', '1\n2\n3\n4'); |
| 54 list.updateSizeForItem(0); |
| 55 assert.isAbove(firstItem.offsetHeight, initHeight*3); |
| 56 |
| 57 list.set('items.0.index', '1'); |
| 58 list.updateSizeForItem(0); |
| 59 assert.equal(firstItem.offsetHeight, initHeight); |
| 60 |
| 61 done(); |
| 62 }); |
| 63 }); |
| 64 |
| 65 test('update size using item object', function(done) { |
| 66 list.items = buildDataSet(100); |
| 67 |
| 68 flush(function() { |
| 69 var firstItem = getFirstItemFromList(list); |
| 70 var initHeight = firstItem.offsetHeight; |
| 71 |
| 72 list.set('items.0.index', '1\n2\n3\n4'); |
| 73 list.updateSizeForItem(list.items[0]); |
| 74 assert.isAbove(firstItem.offsetHeight, initHeight*3); |
| 75 |
| 76 list.set('items.0.index', '1'); |
| 77 list.updateSizeForItem(list.items[0]); |
| 78 assert.equal(firstItem.offsetHeight, initHeight); |
| 79 |
| 80 done(); |
| 81 }); |
| 82 }); |
| 83 |
| 84 test('ignore items that are not rendered', function(done) { |
| 85 list.items = buildDataSet(100); |
| 86 |
| 87 flush(function() { |
| 88 list.updateSizeForItem(list.items[list._physicalCount + 1]); |
| 89 done(); |
| 90 }); |
| 91 }); |
| 92 |
| 93 |
| 94 test('throw if the item is invalid', function(done) { |
| 95 list.items = buildDataSet(100); |
| 96 |
| 97 flush(function() { |
| 98 var firstItem = getFirstItemFromList(list); |
| 99 var initHeight = firstItem.offsetHeight; |
| 100 var throws = 0; |
| 101 |
| 102 try { |
| 103 list.updateSizeForItem(100); |
| 104 } catch (error) { |
| 105 throws++; |
| 106 } |
| 107 |
| 108 try { |
| 109 list.updateSizeForItem({}); |
| 110 } catch (error) { |
| 111 throws++; |
| 112 } |
| 113 |
| 114 assert.equal(throws, 2); |
| 115 done(); |
| 116 }); |
| 117 }); |
| 118 |
| 119 }); |
| 120 |
| 121 </script> |
| 122 |
| 123 </body> |
| 124 </html> |
OLD | NEW |