get_child_elements_test.dart 668 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
import 'dart:sky';

import 'package:test/test.dart';

void main() {
  test("getChildElements should only include immediate children", () {
    var doc = new Document();
    var parent = doc.createElement('parent');
    var child1 = doc.createElement('child1');
    var child2 = doc.createElement('child1');
    var grandchild = doc.createElement('grandchild');

    doc.appendChild(parent);
    parent.appendChild(child1);
    parent.appendChild(child2);
    child1.appendChild(grandchild);

    var children = parent.getChildElements();
    expect(children.length, equals(2));
    expect(children[0], equals(child1));
    expect(children[1], equals(child2));
  });
}