OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 @TestOn('browser') | 4 @TestOn('browser') |
5 library polymer_elements.test.iron_autogrow_textarea_test; | 5 library polymer_elements.test.iron_autogrow_textarea_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'package:polymer_elements/iron_autogrow_textarea.dart'; | 8 import 'package:polymer_elements/iron_autogrow_textarea.dart'; |
9 import 'package:test/test.dart'; | 9 import 'package:test/test.dart'; |
10 import 'package:web_components/web_components.dart'; | 10 import 'package:web_components/web_components.dart'; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 test('removing rows shrinks the textarea', () { | 44 test('removing rows shrinks the textarea', () { |
45 IronAutogrowTextarea autogrow = fixture('basic'); | 45 IronAutogrowTextarea autogrow = fixture('basic'); |
46 autogrow.bindValue = 'batman\nand\nrobin'; | 46 autogrow.bindValue = 'batman\nand\nrobin'; |
47 var initialHeight = autogrow.offsetHeight; | 47 var initialHeight = autogrow.offsetHeight; |
48 autogrow.bindValue = 'batman'; | 48 autogrow.bindValue = 'batman'; |
49 var finalHeight = autogrow.offsetHeight; | 49 var finalHeight = autogrow.offsetHeight; |
50 expect(finalHeight < initialHeight, isTrue); | 50 expect(finalHeight < initialHeight, isTrue); |
51 }); | 51 }); |
52 | 52 |
| 53 test('an undefined bindValue is the empty string', () { |
| 54 IronAutogrowTextarea autogrow = fixture('basic'); |
| 55 var initialHeight = autogrow.offsetHeight; |
| 56 |
| 57 autogrow.bindValue = 'batman\nand\nrobin'; |
| 58 var finalHeight = autogrow.offsetHeight; |
| 59 expect(finalHeight , greaterThan(initialHeight)); |
| 60 |
| 61 autogrow.bindValue = null; |
| 62 expect(autogrow.offsetHeight, initialHeight); |
| 63 expect(autogrow.textarea.value, ''); |
| 64 }); |
| 65 |
53 test('textarea selection works', () { | 66 test('textarea selection works', () { |
54 IronAutogrowTextarea autogrow = fixture('basic'); | 67 IronAutogrowTextarea autogrow = fixture('basic'); |
55 var textarea = autogrow.textarea; | 68 var textarea = autogrow.textarea; |
56 autogrow.bindValue = 'batman\nand\nrobin'; | 69 autogrow.bindValue = 'batman\nand\nrobin'; |
57 | 70 |
58 autogrow.selectionStart = 3; | 71 autogrow.selectionStart = 3; |
59 autogrow.selectionEnd = 5; | 72 autogrow.selectionEnd = 5; |
60 | 73 |
61 expect(textarea.selectionStart, 3); | 74 expect(textarea.selectionStart, 3); |
62 expect(textarea.selectionEnd, 5); | 75 expect(textarea.selectionEnd, 5); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 test('a required textarea with no text is invalid', () { | 111 test('a required textarea with no text is invalid', () { |
99 IronAutogrowTextarea input = fixture('basic'); | 112 IronAutogrowTextarea input = fixture('basic'); |
100 input.required = true; | 113 input.required = true; |
101 expect(input.validate(), isFalse); | 114 expect(input.validate(), isFalse); |
102 input.bindValue = 'batman'; | 115 input.bindValue = 'batman'; |
103 expect(input.validate(), isTrue); | 116 expect(input.validate(), isTrue); |
104 }); | 117 }); |
105 }); | 118 }); |
106 }); | 119 }); |
107 } | 120 } |
OLD | NEW |