| Index: third_party/polymer/v0_8/components-chromium/iron-selector/test/template-repeat.html
|
| diff --git a/third_party/polymer/v0_8/components-chromium/iron-selector/test/template-repeat.html b/third_party/polymer/v0_8/components-chromium/iron-selector/test/template-repeat.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..34b9171b332360c16c901d77aa2f2d53c9397b17
|
| --- /dev/null
|
| +++ b/third_party/polymer/v0_8/components-chromium/iron-selector/test/template-repeat.html
|
| @@ -0,0 +1,111 @@
|
| +<!doctype html>
|
| +<!--
|
| +Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
| +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
| +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
| +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
| +Code distributed by Google as part of the polymer project is also
|
| +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
| +-->
|
| +
|
| +<html>
|
| +<head>
|
| +
|
| + <title>iron-selector-template-repeat</title>
|
| + <meta charset="utf-8">
|
| + <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
|
| +
|
| + <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
| + <script src="../../web-component-tester/browser.js"></script>
|
| + <script src="../../test-fixture/test-fixture-mocha.js"></script>
|
| +
|
| + <link rel="import" href="../../test-fixture/test-fixture.html">
|
| + <link rel="import" href="../iron-selector.html">
|
| +
|
| + <style>
|
| + .iron-selected {
|
| + background: #ccc;
|
| + }
|
| + </style>
|
| +
|
| +</head>
|
| +<body>
|
| +
|
| + <test-fixture id="test">
|
| + <template>
|
| + <iron-selector id="selector" selected="1">
|
| + <template id="t" is="x-repeat">
|
| + <div id$="[[item.name]]">{{item.name}}</div>
|
| + </template>
|
| + </iron-selector>
|
| + </template>
|
| + </test-fixture>
|
| +
|
| + <script>
|
| +
|
| + suite('x-repeat', function() {
|
| +
|
| + var s, t;
|
| +
|
| + setup(function () {
|
| + s = fixture('test');
|
| + t = s.querySelector('#t');
|
| + });
|
| +
|
| + test('supports repeated items', function(done) {
|
| + t.items = [{name:'item0'}, {name: 'item1'}, {name: 'item2'}, {name: 'item3'}];
|
| + setTimeout(function() {
|
| + // check items
|
| + assert.equal(s.items.length, 4);
|
| + // check selected
|
| + assert.equal(s.selected, 1);
|
| + // check selected item
|
| + var item = s.selectedItem;
|
| + assert.equal(s.items[1], item);
|
| + // check selected class
|
| + assert.isTrue(item.classList.contains('iron-selected'));
|
| + done();
|
| + });
|
| + });
|
| +
|
| + test('update items', function(done) {
|
| + t.items = [{name:'item0'}, {name: 'item1'}, {name: 'item2'}, {name: 'item3'}];
|
| + setTimeout(function() {
|
| + // check items
|
| + assert.equal(s.items.length, 4);
|
| + // check selected
|
| + assert.equal(s.selected, 1);
|
| + // update items
|
| + t.items = [{name:'foo'}, {name: 'bar'}];
|
| + setTimeout(function() {
|
| + // check items
|
| + assert.equal(s.items.length, 2);
|
| + // check selected (should still honor the selected)
|
| + assert.equal(s.selected, 1);
|
| + // check selected class
|
| + assert.isTrue(s.querySelector('#bar').classList.contains('iron-selected'));
|
| + done();
|
| + });
|
| + });
|
| + });
|
| +
|
| + test('set selected to something else', function(done) {
|
| + t.items = [{name:'item0'}, {name: 'item1'}, {name: 'item2'}, {name: 'item3'}];
|
| + setTimeout(function() {
|
| + // set selected to something else
|
| + s.selected = 3;
|
| + // check selected item
|
| + var item = s.selectedItem;
|
| + assert.equal(s.items[3], item);
|
| + // check selected class
|
| + assert.isTrue(item.classList.contains('iron-selected'));
|
| + done();
|
| + });
|
| + });
|
| +
|
| + });
|
| +
|
| + </script>
|
| +
|
| +</body>
|
| +</html>
|
|
|