OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <!-- | 2 <!-- |
3 @license | 3 @license |
4 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. | 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.txt | 5 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
6 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | 6 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
7 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt | 7 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
8 Code distributed by Google as part of the polymer project is also | 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.txt | 9 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
10 --> | 10 --> |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 suite('when a value is preselected', function() { | 112 suite('when a value is preselected', function() { |
113 setup(function() { | 113 setup(function() { |
114 dropdownMenu = fixture('PreselectedDropdownMenu'); | 114 dropdownMenu = fixture('PreselectedDropdownMenu'); |
115 }); | 115 }); |
116 | 116 |
117 test('the input area shows the correct selection', function() { | 117 test('the input area shows the correct selection', function() { |
118 var secondItem = Polymer.dom(dropdownMenu).querySelectorAll('paper-ite
m')[1]; | 118 var secondItem = Polymer.dom(dropdownMenu).querySelectorAll('paper-ite
m')[1]; |
119 expect(dropdownMenu.selectedItem).to.be.equal(secondItem); | 119 expect(dropdownMenu.selectedItem).to.be.equal(secondItem); |
120 }); | 120 }); |
121 }); | 121 }); |
| 122 |
| 123 suite('deselecting', function() { |
| 124 var menu; |
| 125 |
| 126 setup(function() { |
| 127 dropdownMenu = fixture('PreselectedDropdownMenu'); |
| 128 menu = Polymer.dom(dropdownMenu).querySelector('.dropdown-content'); |
| 129 }); |
| 130 |
| 131 test('an `iron-deselect` event clears the current selection', function()
{ |
| 132 menu.selected = null; |
| 133 expect(dropdownMenu.selectedItem).to.be.equal(null); |
| 134 }); |
| 135 }); |
| 136 |
| 137 suite('validation', function() { |
| 138 test('a non required dropdown is valid regardless of its selection', fun
ction() { |
| 139 var dropdownMenu = fixture('TrivialDropdownMenu'); |
| 140 menu = Polymer.dom(dropdownMenu).querySelector('.dropdown-content'); |
| 141 |
| 142 // no selection. |
| 143 expect(dropdownMenu.validate()).to.be.true; |
| 144 expect(dropdownMenu.invalid).to.be.false; |
| 145 expect(dropdownMenu.value).to.not.be.ok; |
| 146 |
| 147 // some selection. |
| 148 menu.selected = 1; |
| 149 expect(dropdownMenu.validate()).to.be.true; |
| 150 expect(dropdownMenu.invalid).to.be.false; |
| 151 expect(dropdownMenu.value).to.be.equal('Bar'); |
| 152 }); |
| 153 |
| 154 test('a required dropdown is invalid without a selection', function() { |
| 155 var dropdownMenu = fixture('TrivialDropdownMenu'); |
| 156 dropdownMenu.required = true; |
| 157 |
| 158 // no selection. |
| 159 expect(dropdownMenu.validate()).to.be.false; |
| 160 expect(dropdownMenu.invalid).to.be.true; |
| 161 expect(dropdownMenu.value).to.not.be.ok; |
| 162 }); |
| 163 |
| 164 test('a required dropdown is valid with a selection', function() { |
| 165 var dropdownMenu = fixture('PreselectedDropdownMenu'); |
| 166 dropdownMenu.required = true; |
| 167 |
| 168 expect(dropdownMenu.validate()).to.be.true; |
| 169 expect(dropdownMenu.invalid).to.be.false; |
| 170 expect(dropdownMenu.value).to.be.equal('Bar'); |
| 171 }); |
| 172 }); |
122 }); | 173 }); |
123 </script> | 174 </script> |
124 | 175 |
125 </body> | 176 </body> |
126 </html> | 177 </html> |
OLD | NEW |