Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
|
vsm
2012/08/22 18:22:27
s/2011/2012/
blois
2012/08/22 20:06:13
Done.
| |
| 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 // Put universally passing event constructors in this file. | |
|
vsm
2012/08/22 18:22:27
This comment doesn't seem to match this test.
blois
2012/08/22 20:06:13
D'oh. Copy paste :(
| |
| 6 // Move constructors that fail on some configuration to their own | |
| 7 // element_constructor_foo_test.dart file. | |
| 8 | |
| 9 #library('ElementAddTest'); | |
| 10 #import('../../lib/unittest/unittest.dart'); | |
| 11 #import('../../lib/unittest/html_config.dart'); | |
| 12 #import('dart:html'); | |
| 13 #source('util.dart'); | |
| 14 | |
| 15 main() { | |
| 16 useHtmlConfiguration(); | |
| 17 | |
| 18 void expectNoSuchMethod(void fn()) => | |
| 19 Expect.throws(fn, (e) => e is NoSuchMethodException); | |
| 20 | |
| 21 group('addHTML', () { | |
| 22 test('htmlelement', () { | |
| 23 // Adding a <tr/> to a table should auto-wrap it into a tbody element. | |
| 24 var el = new TableElement(); | |
| 25 el.addHTML('<tr>test</tr>'); | |
| 26 Expect.equals(1, el.elements.length); | |
|
vsm
2012/08/22 18:22:27
Sorry this isn't clear anywhere, but the old Expec
blois
2012/08/22 20:06:13
Done.
| |
| 27 var section = el.elements[0]; | |
| 28 Expect.isTrue(section is TableSectionElement); | |
|
vsm
2012/08/22 18:22:27
expect(section is TableSectionElement);
blois
2012/08/22 20:06:13
Done.
| |
| 29 Expect.equals(1, section.elements.length); | |
| 30 Expect.isTrue(section.elements[0] is TableRowElement); | |
|
vsm
2012/08/22 18:22:27
How about testing a second add to ensure that it's
blois
2012/08/22 20:06:13
Done.
| |
| 31 }); | |
| 32 | |
| 33 test('documentFragment', () { | |
| 34 var fragment = new DocumentFragment(); | |
| 35 fragment.addHTML('<span>something</span>'); | |
| 36 Expect.equals(1, fragment.elements.length); | |
| 37 Expect.isTrue(fragment.elements[0] is SpanElement); | |
| 38 }); | |
| 39 | |
| 40 test('svg', () { | |
| 41 var svg = new SVGElement.tag('g'); | |
| 42 expectNoSuchMethod(() => svg.addHTML('<rect/>'));; | |
| 43 }); | |
| 44 }); | |
| 45 | |
| 46 group('addText', () { | |
| 47 test('htmlelement', () { | |
| 48 var el = new DivElement(); | |
| 49 el.addText('foo'); | |
| 50 // No elements were created. | |
| 51 Expect.equals(0, el.elements.length); | |
| 52 // One text node was added. | |
| 53 Expect.equals(1, el.nodes.length); | |
| 54 }); | |
| 55 | |
| 56 test('documentFragment', () { | |
| 57 var fragment = new DocumentFragment(); | |
| 58 fragment.addText('foo'); | |
| 59 // No elements were created. | |
| 60 Expect.equals(0, fragment.elements.length); | |
| 61 // One text node was added. | |
| 62 Expect.equals(1, fragment.nodes.length); | |
| 63 }); | |
| 64 | |
| 65 test('svg', () { | |
| 66 var svg = new SVGElement.tag('g'); | |
| 67 expectNoSuchMethod(() => svg.addText('foo')); | |
| 68 }); | |
| 69 }); | |
| 70 } | |
| OLD | NEW |