OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 | 4 |
5 library selectelement_test; | 5 library selectelement_test; |
6 import '../../pkg/unittest/lib/unittest.dart'; | 6 import '../../pkg/unittest/lib/unittest.dart'; |
7 import '../../pkg/unittest/lib/html_config.dart'; | 7 import '../../pkg/unittest/lib/html_config.dart'; |
8 import 'dart:html'; | 8 import 'dart:html'; |
9 | 9 |
10 main() { | 10 main() { |
11 useHtmlConfiguration(); | 11 useHtmlConfiguration(); |
12 | 12 |
13 test('selectedOptions', () { | 13 test('selectedOptions', () { |
14 var element = new SelectElement(); | 14 var element = new SelectElement(); |
15 element.multiple = false; | 15 element.multiple = false; |
16 var options = [ | 16 var options = [ |
17 new OptionElement(), | 17 new OptionElement(), |
18 new DivElement(), | 18 new DivElement(), |
19 new OptionElement('data', 'two', false, true), | 19 new OptionElement('data', 'two', false, true), |
20 new DivElement(), | 20 new DivElement(), |
21 new OptionElement('data', 'two', false, true), | 21 new OptionElement('data', 'two', false, true), |
22 new OptionElement(), | 22 new OptionElement(), |
23 ]; | 23 ]; |
24 element.elements.addAll(options); | 24 element.children.addAll(options); |
25 expect(element.selectedOptions.length, 1); | 25 expect(element.selectedOptions.length, 1); |
26 expect(element.selectedOptions[0], equals(options[4])); | 26 expect(element.selectedOptions[0], equals(options[4])); |
27 }); | 27 }); |
28 | 28 |
29 test('multiple selectedOptions', () { | 29 test('multiple selectedOptions', () { |
30 var element = new SelectElement(); | 30 var element = new SelectElement(); |
31 element.multiple = true; | 31 element.multiple = true; |
32 var options = [ | 32 var options = [ |
33 new OptionElement(), | 33 new OptionElement(), |
34 new DivElement(), | 34 new DivElement(), |
35 new OptionElement('data', 'two', false, true), | 35 new OptionElement('data', 'two', false, true), |
36 new DivElement(), | 36 new DivElement(), |
37 new OptionElement('data', 'two', false, true), | 37 new OptionElement('data', 'two', false, true), |
38 new OptionElement(), | 38 new OptionElement(), |
39 ]; | 39 ]; |
40 element.elements.addAll(options); | 40 element.children.addAll(options); |
41 expect(element.selectedOptions.length, 2); | 41 expect(element.selectedOptions.length, 2); |
42 expect(element.selectedOptions[0], equals(options[2])); | 42 expect(element.selectedOptions[0], equals(options[2])); |
43 expect(element.selectedOptions[1], equals(options[4])); | 43 expect(element.selectedOptions[1], equals(options[4])); |
44 }); | 44 }); |
45 | 45 |
46 test('options', () { | 46 test('options', () { |
47 var element = new SelectElement(); | 47 var element = new SelectElement(); |
48 var options = [ | 48 var options = [ |
49 new OptionElement(), | 49 new OptionElement(), |
50 new OptionElement('data', 'two', false, true), | 50 new OptionElement('data', 'two', false, true), |
51 new OptionElement('data', 'two', false, true), | 51 new OptionElement('data', 'two', false, true), |
52 new OptionElement(), | 52 new OptionElement(), |
53 ]; | 53 ]; |
54 element.elements.addAll(options); | 54 element.children.addAll(options); |
55 // Use last to make sure that the list was correctly wrapped. | 55 // Use last to make sure that the list was correctly wrapped. |
56 expect(element.options.last, equals(options[3])); | 56 expect(element.options.last, equals(options[3])); |
57 }); | 57 }); |
58 } | 58 } |
OLD | NEW |