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.github.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/CONTRIBUTORS
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/PATENTS
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">
17
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
18
<script src="../../web-component-tester/browser.js"></script>
19
<script src="../../iron-test-helpers/mock-interactions.js"></script>
21
<link rel="import" href="helpers.html">
22
<link rel="import" href="x-list.html">
27
<test-fixture id="trivialList">
29
<x-list item-height="0" pre></x-list>
35
suite('Dynamic item size', function() {
39
container = fixture('trivialList');
40
list = container.list;
43
test('update size using item index', function(done) {
44
list.items = buildDataSet(100);
47
var firstItem = getFirstItemFromList(list);
48
var initHeight = firstItem.offsetHeight;
50
list.set('items.0.index', '1\n2\n3\n4');
51
list.updateSizeForItem(0);
52
assert.isAbove(firstItem.offsetHeight, initHeight*3);
54
list.set('items.0.index', '1');
55
list.updateSizeForItem(0);
56
assert.equal(firstItem.offsetHeight, initHeight);
62
test('update size using item object', function(done) {
63
list.items = buildDataSet(100);
66
var firstItem = getFirstItemFromList(list);
67
var initHeight = firstItem.offsetHeight;
69
list.set('items.0.index', '1\n2\n3\n4');
70
list.updateSizeForItem(list.items[0]);
71
assert.isAbove(firstItem.offsetHeight, initHeight*3);
73
list.set('items.0.index', '1');
74
list.updateSizeForItem(list.items[0]);
75
assert.equal(firstItem.offsetHeight, initHeight);
81
test('ignore items that are not rendered', function(done) {
82
list.items = buildDataSet(100);
85
list.updateSizeForItem(list.items[list.items.length - 1]);
91
test('throw if the item is invalid', function(done) {
92
list.items = buildDataSet(100);
95
var firstItem = getFirstItemFromList(list);
96
var initHeight = firstItem.offsetHeight;
100
list.updateSizeForItem(100);
106
list.updateSizeForItem({});
111
assert.equal(throws, 2);