| OLD | NEW |
| (Empty) |
| 1 <!-- | |
| 2 Copyright 2014 The Chromium Authors. All rights reserved. | |
| 3 Use of this source code is governed by a BSD-style license that can be | |
| 4 found in the LICENSE file. | |
| 5 --> | |
| 6 | |
| 7 <link rel="import" href="../ct-tree-select.html"> | |
| 8 | |
| 9 <link rel="import" href="../../model/ct-tree-list.html"> | |
| 10 | |
| 11 <script> | |
| 12 (function () { | |
| 13 | |
| 14 var assert = chai.assert; | |
| 15 | |
| 16 describe('ct-tree-select', function() { | |
| 17 var select; | |
| 18 | |
| 19 beforeEach(function(done) { | |
| 20 select = document.createElement('ct-tree-select'); | |
| 21 setTimeout(done); | |
| 22 }); | |
| 23 | |
| 24 describe('tree select UI', function() { | |
| 25 beforeEach(function(done) { | |
| 26 var treeList = new CTTreeList(); | |
| 27 treeList.trees = [new CTTree("tree1", "Tree 1"), new CTTree("tree2", "Tree
2")]; | |
| 28 | |
| 29 // This represents initialization that should be normally be done on this
component. | |
| 30 select.treeList = treeList; | |
| 31 select.tree = treeList.defaultValue(); | |
| 32 | |
| 33 setTimeout(done); | |
| 34 }); | |
| 35 | |
| 36 it('should show two elements, first one selected', function() { | |
| 37 var options = select.shadowRoot.querySelectorAll('option'); | |
| 38 assert.lengthOf(options, 2); | |
| 39 assert(options[0].selected); | |
| 40 assert(!options[1].selected); | |
| 41 assert.equal(select.treeList.trees[0].name, select.tree); | |
| 42 }); | |
| 43 | |
| 44 describe('expanded test', function() { | |
| 45 beforeEach(function(done) { | |
| 46 var selectElement = select.shadowRoot.querySelectorAll('select')[0]; | |
| 47 selectElement.selectedIndex = 1; | |
| 48 | |
| 49 var event = new CustomEvent('change'); | |
| 50 selectElement.dispatchEvent(event); | |
| 51 setTimeout(done); | |
| 52 }); | |
| 53 | |
| 54 it('should have the second value as its "tree"', function() { | |
| 55 assert.equal(select.treeList.trees[1].name, select.tree); | |
| 56 }); | |
| 57 }); | |
| 58 }); | |
| 59 }); | |
| 60 | |
| 61 })() | |
| 62 </script> | |
| OLD | NEW |