| OLD | NEW |
| (Empty) |
| 1 #import('../../../../../dart/client/testing/unittest/unittest.dart'); | |
| 2 #import('dart:dom'); | |
| 3 | |
| 4 main() { | |
| 5 forLayoutTests(); | |
| 6 test('InnerHTML', () { | |
| 7 HTMLElement element = document.createElement('div'); | |
| 8 element.id = 'test'; | |
| 9 element.innerHTML = 'Hello World'; | |
| 10 document.body.appendChild(element); | |
| 11 | |
| 12 element = document.getElementById('test'); | |
| 13 Expect.stringEquals('Hello World', element.innerHTML); | |
| 14 document.body.removeChild(element); | |
| 15 }); | |
| 16 test('HTMLTable', () { | |
| 17 HTMLElement table = document.createElement('table'); | |
| 18 | |
| 19 HTMLTableRowElement row = document.createElement('tr'); | |
| 20 table.appendChild(row); | |
| 21 | |
| 22 row.appendChild(document.createElement('td')); | |
| 23 row.appendChild(document.createElement('td')); | |
| 24 | |
| 25 Expect.equals(2, row.cells.length); | |
| 26 | |
| 27 HTMLTableRowElement headerRow = table.rows.item(0); | |
| 28 Expect.equals(2, headerRow.cells.length); | |
| 29 }); | |
| 30 test('Dataset', () { | |
| 31 HTMLElement div = document.createElement('div'); | |
| 32 | |
| 33 Expect.isTrue(div.dataset.isEmpty()); | |
| 34 Expect.equals('', div.dataset['foo']); | |
| 35 Expect.isTrue(div.dataset.isEmpty()); | |
| 36 | |
| 37 div.dataset['foo'] = 'foo-value'; | |
| 38 Expect.equals('foo-value', div.dataset['foo']); | |
| 39 Expect.isFalse(div.dataset.isEmpty()); | |
| 40 | |
| 41 Expect.isTrue(div.dataset.containsValue('foo-value')); | |
| 42 Expect.isFalse(div.dataset.containsValue('bar-value')); | |
| 43 Expect.isTrue(div.dataset.containsKey('foo')); | |
| 44 Expect.isFalse(div.dataset.containsKey('bar')); | |
| 45 | |
| 46 bool hasBeenInvoked; | |
| 47 String f() { | |
| 48 hasBeenInvoked = true; | |
| 49 return 'bar-value'; | |
| 50 } | |
| 51 | |
| 52 hasBeenInvoked = false; | |
| 53 Expect.equals('bar-value', div.dataset.putIfAbsent('bar', f)); | |
| 54 Expect.isTrue(hasBeenInvoked); | |
| 55 | |
| 56 hasBeenInvoked = false; | |
| 57 Expect.equals('bar-value', div.dataset.putIfAbsent('bar', f)); | |
| 58 Expect.isFalse(hasBeenInvoked); | |
| 59 | |
| 60 final keys = <String> []; | |
| 61 final values = <String> []; | |
| 62 div.dataset.forEach(void f(String key, String value) { | |
| 63 keys.add(key); | |
| 64 values.add(value); | |
| 65 }); | |
| 66 Expect.setEquals(const <String> ['foo', 'bar'], keys); | |
| 67 Expect.setEquals(const <String> ['foo-value', 'bar-value'], values); | |
| 68 | |
| 69 Expect.setEquals(const <String> ['foo', 'bar'], | |
| 70 new List<String>.from(div.dataset.getKeys())); | |
| 71 Expect.setEquals(const <String> ['foo-value', 'bar-value'], | |
| 72 new List<String>.from(div.dataset.getValues())); | |
| 73 | |
| 74 Expect.equals(2, div.dataset.length); | |
| 75 Expect.isFalse(div.dataset.isEmpty()); | |
| 76 | |
| 77 Expect.isNull(div.dataset.remove('qux')); | |
| 78 Expect.equals(2, div.dataset.length); | |
| 79 Expect.isFalse(div.dataset.isEmpty()); | |
| 80 | |
| 81 Expect.equals('foo-value', div.dataset.remove('foo')); | |
| 82 Expect.equals(1, div.dataset.length); | |
| 83 Expect.isFalse(div.dataset.isEmpty()); | |
| 84 | |
| 85 div.dataset.clear(); | |
| 86 Expect.equals(0, div.dataset.length); | |
| 87 Expect.isTrue(div.dataset.isEmpty()); | |
| 88 }); | |
| 89 } | |
| OLD | NEW |