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 FormElementTest; | 5 library FormElementTest; |
6 | 6 |
7 import 'package:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
8 import 'package:unittest/html_config.dart'; | 8 import 'package:unittest/html_config.dart'; |
9 import 'dart:html'; | 9 import 'dart:html'; |
10 | 10 |
11 void main() { | 11 void main() { |
12 useHtmlConfiguration(); | 12 useHtmlConfiguration(); |
13 | 13 |
14 var isFormElement = predicate((x) => x is FormElement, 'is a FormElement'); | 14 var isFormElement = predicate((x) => x is FormElement, 'is a FormElement'); |
15 | 15 |
16 test('constructorTest1', () { | 16 test('constructorTest1', () { |
17 var form = new FormElement(); | 17 var form = new FormElement(); |
18 expect(form, isNotNull); | 18 expect(form, isNotNull); |
19 expect(form, isFormElement); | 19 expect(form, isFormElement); |
20 }); | 20 }); |
21 | 21 |
22 test('checkValidityTest', () { | 22 test('checkValidityTest', () { |
23 var form = new FormElement(); | 23 var form = new FormElement(); |
24 form.innerHtml = '<label>Google: <input type="search" name="q"></label> ' | 24 form.innerHtml = '<label>Google: <input type="search" name="q"></label> ' |
25 '<input type="submit" value="Search...">'; | 25 '<input type="submit" value="Search...">'; |
26 expect(form.checkValidity(), isTrue); | 26 expect(form.checkValidity(), isTrue); |
27 // TODO(efortuna): Issue 4832. | 27 // TODO(efortuna): Issue 4832. |
28 form.innerHtml = '<input type="email" value="notemail" blaber="test"' | 28 form.innerHtml = '<input type="email" value="notemail" blaber="test"' |
29 ' required>'; | 29 ' required>'; |
30 expect(form.checkValidity(), isFalse); | 30 expect(form.checkValidity(), isFalse); |
31 }); | 31 }); |
32 | 32 |
33 var form = new FormElement(); | 33 var form = new FormElement(); |
34 test('acceptCharsetTest', () { | 34 test('acceptCharsetTest', () { |
35 var charset = 'abc'; | 35 var charset = 'abc'; |
36 form.acceptCharset = charset; | 36 form.acceptCharset = charset; |
37 expect(form.acceptCharset, charset); | 37 expect(form.acceptCharset, charset); |
38 }); | 38 }); |
39 | 39 |
40 test('actionTest', () { | 40 test('actionTest', () { |
41 var action = 'http://dartlang.org/'; | 41 var action = 'http://dartlang.org/'; |
42 form.action = action; | 42 form.action = action; |
43 expect(form.action, action); | 43 expect(form.action, action); |
44 }); | 44 }); |
45 | 45 |
46 test('autocompleteTest', () { | 46 test('autocompleteTest', () { |
47 var auto = 'on'; | 47 var auto = 'on'; |
48 form.autocomplete = auto; | 48 form.autocomplete = auto; |
49 expect(form.autocomplete, auto); | 49 expect(form.autocomplete, auto); |
50 }); | 50 }); |
51 | 51 |
52 test('encodingAndEnctypeTest', () { | 52 test('encodingAndEnctypeTest', () { |
53 expect(form.enctype, form.encoding); | 53 expect(form.enctype, form.encoding); |
54 }); | 54 }); |
55 | 55 |
56 test('lengthTest', () { | 56 test('lengthTest', () { |
57 expect(form.length, 0); | 57 expect(form.length, 0); |
58 form.innerHtml = '<label>Google: <input type="search" name="q"></label> ' | 58 form.innerHtml = '<label>Google: <input type="search" name="q"></label> ' |
59 '<input type="submit" value="Search...">'; | 59 '<input type="submit" value="Search...">'; |
60 expect(form.length, 2); | 60 expect(form.length, 2); |
61 }); | 61 }); |
62 | 62 |
63 test('methodTest', () { | 63 test('methodTest', () { |
64 var method = 'post'; | 64 var method = 'post'; |
65 form.method = method; | 65 form.method = method; |
66 expect(form.method, method); | 66 expect(form.method, method); |
67 }); | 67 }); |
68 | 68 |
69 test('nameTest', () { | 69 test('nameTest', () { |
70 var name = 'aname'; | 70 var name = 'aname'; |
71 form.name = name; | 71 form.name = name; |
72 expect(form.name, name); | 72 expect(form.name, name); |
73 }); | 73 }); |
74 | 74 |
75 test('noValidateTest', () { | 75 test('noValidateTest', () { |
76 form.noValidate = true; | 76 form.noValidate = true; |
77 expect(form.noValidate, true); | 77 expect(form.noValidate, true); |
78 }); | 78 }); |
79 | 79 |
80 test('targetTest', () { | 80 test('targetTest', () { |
81 var target = 'target'; | 81 var target = 'target'; |
82 form.target = target; | 82 form.target = target; |
83 expect(form.target, target); | 83 expect(form.target, target); |
84 }); | 84 }); |
85 } | 85 } |
OLD | NEW |