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 import 'dart:html'; | 5 import 'dart:html'; |
6 | 6 |
7 import 'package:expect/minitest.dart'; | 7 import 'package:expect/minitest.dart'; |
8 | 8 |
9 main() { | 9 main() { |
10 test('indexedAccessTest', () { | 10 test('indexedAccessTest', () { |
11 // FIXME: we need some massaging to dart:html to enable HTMLOptionsCollectio
n.add | 11 // FIXME: we need some massaging to dart:html to enable HTMLOptionsCollectio
n.add |
12 // and hence programatic building of collection. | 12 // and hence programatic building of collection. |
13 SelectElement selectElement = new Element.html(''' | 13 SelectElement selectElement = new Element.html(''' |
14 <select> | 14 <select> |
15 <option value="0">Option0</option> | 15 <option value="0">Option0</option> |
16 <option value="1">Option1</option> | 16 <option value="1">Option1</option> |
17 <option value="2">Option2</option> | 17 <option value="2">Option2</option> |
18 '''); | 18 '''); |
19 final optionsCollection = selectElement.options; | 19 final optionsCollection = selectElement.options; |
20 | 20 |
21 expect(optionsCollection[0].value, equals('0')); | 21 expect(optionsCollection[0].value, equals('0')); |
22 expect(optionsCollection[1].value, equals('1')); | 22 expect(optionsCollection[1].value, equals('1')); |
23 expect(optionsCollection[2].value, equals('2')); | 23 expect(optionsCollection[2].value, equals('2')); |
24 | 24 |
25 expect(optionsCollection[0].text, equals('Option0')); | 25 expect(optionsCollection[0].text, equals('Option0')); |
26 expect(optionsCollection[1].text, equals('Option1')); | 26 expect(optionsCollection[1].text, equals('Option1')); |
27 expect(optionsCollection[2].text, equals('Option2')); | 27 expect(optionsCollection[2].text, equals('Option2')); |
28 | 28 |
29 expect(() { (optionsCollection as dynamic)[0] = 1; }, throws); | 29 expect(() { |
| 30 (optionsCollection as dynamic)[0] = 1; |
| 31 }, throws); |
30 | 32 |
31 // OPTIONALS optionsCollection[0] = new OptionElement(value: '42', data: 'Op
tion42'); | 33 // OPTIONALS optionsCollection[0] = new OptionElement(value: '42', data: 'Op
tion42'); |
32 expect(() { | 34 expect(() { |
33 optionsCollection[0] = new OptionElement(data: 'Option42', value: '42'); | 35 optionsCollection[0] = new OptionElement(data: 'Option42', value: '42'); |
34 }, throws); | 36 }, throws); |
35 }); | 37 }); |
36 } | 38 } |
OLD | NEW |