|
40 | 40 | </template> |
41 | 41 | </test-fixture> |
42 | 42 |
|
| 43 | + <test-fixture id="prefix"> |
| 44 | + <template> |
| 45 | + <paper-input-container> |
| 46 | + <div prefix>$</div> |
| 47 | + <label id="l">label</label> |
| 48 | + <input is="iron-input" id="i"> |
| 49 | + </paper-input-container> |
| 50 | + </template> |
| 51 | + </test-fixture> |
| 52 | + |
| 53 | + <test-fixture id="prefix-has-value"> |
| 54 | + <template> |
| 55 | + <paper-input-container> |
| 56 | + <div prefix>$</div> |
| 57 | + <label id="l">label</label> |
| 58 | + <input is="iron-input" id="i" value="foo"> |
| 59 | + </paper-input-container> |
| 60 | + </template> |
| 61 | + </test-fixture> |
| 62 | + |
43 | 63 | <test-fixture id="has-value"> |
44 | 64 | <template> |
45 | 65 | <paper-input-container> |
|
119 | 139 | assert.equal(getComputedStyle(container.querySelector('#l')).visibility, 'visible', 'label has visibility:visible'); |
120 | 140 | }); |
121 | 141 |
|
122 | | - test('label is floated if value is initialized to not null', function() { |
| 142 | + test('label is floated if value is initialized to not null', function(done) { |
123 | 143 | var container = fixture('has-value'); |
124 | | - assert.notEqual(getTransform(container.querySelector('#l')), 'none', 'label has transform'); |
| 144 | + requestAnimationFrame(function() { |
| 145 | + assert.notEqual(getTransform(container.querySelector('#l')), 'none', 'label has transform'); |
| 146 | + done(); |
| 147 | + }); |
125 | 148 | }); |
126 | 149 |
|
127 | 150 | test('label is invisible if no-label-float and value is initialized to not null', function() { |
|
132 | 155 | test('label is floated if always-float-label is true', function() { |
133 | 156 | var container = fixture('always-float'); |
134 | 157 | assert.notEqual(getTransform(container.querySelector('#l')), 'none', 'label has transform'); |
135 | | - }) |
| 158 | + }); |
| 159 | + |
| 160 | + test('label is floated correctly with a prefix', function(done) { |
| 161 | + var container = fixture('prefix'); |
| 162 | + var label = Polymer.dom(container).querySelector('#l'); |
| 163 | + var input = Polymer.dom(container).querySelector('#i'); |
| 164 | + |
| 165 | + // Label is initially visible. |
| 166 | + assert.equal(getComputedStyle(label).visibility, 'visible', 'label has visibility:visible'); |
| 167 | + |
| 168 | + // After entering text, the label floats, and it is not indented. |
| 169 | + input.bindValue = 'foobar'; |
| 170 | + requestAnimationFrame(function() { |
| 171 | + assert.notEqual(getTransform(label), 'none', 'label has transform'); |
| 172 | + assert.equal(label.getBoundingClientRect().left, container.getBoundingClientRect().left); |
| 173 | + done(); |
| 174 | + }); |
| 175 | + }); |
| 176 | + |
| 177 | + test('label is floated correctly with a prefix and prefilled value', function(done) { |
| 178 | + var container = fixture('prefix-has-value'); |
| 179 | + var label = Polymer.dom(container).querySelector('#l'); |
| 180 | + |
| 181 | + // The label floats, and it is not indented. |
| 182 | + requestAnimationFrame(function() { |
| 183 | + assert.notEqual(getTransform(label), 'none', 'label has transform'); |
| 184 | + assert.equal(label.getBoundingClientRect().left, container.getBoundingClientRect().left); |
| 185 | + done(); |
| 186 | + }); |
| 187 | + }); |
136 | 188 |
|
137 | 189 | }); |
138 | 190 |
|
|
0 commit comments