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