const {NODE_TYPES, createElemForNode} = require("./dom-node");
const subtree = require("./subtree");

const divNodeLike = {
  nodeType: NODE_TYPES.ELEMENT_NODE,
  nodeName: "DIV",
  children: []
};

describe("constructSubtreeForNode", () => {
  test("empty children", () => {
    const subTree = subtree.constructSubtreeForNode(document, divNodeLike);
    expect(subTree.tagName).toEqual("DIV");
    expect(subTree.children.length).toEqual(0);
  });

  test("basic children ", () => {
    const subTree = subtree.constructSubtreeForNode(document, {
      ...divNodeLike,
      children: [{
        ...divNodeLike,
        children: [
          divNodeLike,
          divNodeLike,
          divNodeLike
        ]
      }]
    });
    expect(subTree.children.length).toEqual(1);
    expect(subTree.children[0].children.length).toEqual(3);
  });

  test("node callback ", () => {
    const className = 'active';
    const subTree = subtree.constructSubtreeForNode(
      document,
      divNodeLike,
      undefined,
      'all',
      (nodeLike, element) => {
        element.className = className;
        element.setAttribute('data-animation', 'fade');
      }
    );
    expect(subTree.className).toEqual(className);
    expect(subTree.getAttribute('data-animation')).toEqual('fade');
  });
});

@@ -14,27 +14,8 @@
 YPES
-, createElemForNode
 %7D = 
@@ -808,32 +808,337 @@
 oEqual(3);%0A  %7D);
+%0A  %0A  test(%22include iframes%22, () =%3E %7B%0A    const subTree = subtree.constructSubtreeForNode(document, %7B%0A      nodeType: NODE_TYPES.DOCUMENT_NODE,%0A      nodeName: %22#document%22,%0A      contentDocument: %7B%0A        children: %5BdivNodeLike%5D%0A      %7D%0A    %7D, true);%0A    expect(subTree.children.length).toEqual(1);%0A  %7D);
 %0A%0A  test(%22node c
@@ -1389,52 +1389,43 @@
    e
-lement.setAttribute('data-animation', 'fade'
+xpect(nodeLike).toEqual(divNodeLike
 );%0A 
@@ -1492,76 +1492,8 @@
 e);%0A
-    expect(subTree.getAttribute('data-animation')).toEqual('fade');%0A
   %7D)

include iframes