import expect from 'expect.js';
import React from 'react/addons';
const { TestUtils } = React.addons;
import TreePane from '../src/TreePane';


describe('TreePane', function () {


    const model = {
        name: 'Tom',
        children: [
            { name: 'Alice'}, { name: 'Jacob'}
        ]
    };

    const treePane = TestUtils.renderIntoDocument(
        <TreePane model={model} />
    );


    it('should render the tree pane', function () {
        new Asserter(treePane);
    });
});





class Asserter {

    constructor(treePane) {
        this.component = TestUtils.findRenderedDOMComponentWithClass(treePane, 'TreePane');
        this.treePane = treePane;
    }


    assertNumberOfChildren() {
        //expect(this.component.props.children.length).to.equal(3);
    }


    findChildren() {
        //return TestUtils.scryRenderedDOMComponentsWithClass(this.component, 'Node');
    }

}


@@ -174,16 +174,17 @@
  () %7B%0A%0A%0A
+%0A
     cons
@@ -214,11 +214,15 @@
 e: '
-Tom
+Default
 ',%0A 
@@ -265,32 +265,448 @@
 e: '
-Alice'%7D, %7B name: 'Jacob'
+react-tree-pane', children:%5B%0A                %7Bname: 'demo', children: %5B%0A                    %7Bname: 'bundle.js'%7D,%0A                    %7Bname: 'Example.js'%7D%0A                %5D%7D,%0A                %7Bname: 'src', children: %5B%0A                    %7Bname: 'TreePane.js'%7D%0A                %5D%7D,%0A                %7Bname: 'test', children: %5B%0A                    %7Bname: 'TreePane-test.js'%7D%0A                %5D%7D,%0A                %7Bname: 'package.json'%7D%0A            %5D
 %7D%0A  
@@ -721,16 +721,17 @@
     %7D;%0A%0A
+%0A
     cons
@@ -881,16 +881,24 @@
     new 
+TreePane
 Asserter
@@ -921,49 +921,99 @@
 %7D);%0A
-%7D);%0A%0A%0A%0A%0A%0Aclass Asserter %7B%0A%0A    constructo
+%0A%0A    it('should render the whole tree expanded', function () %7B%0A        new TreePaneAsserte
 r(tr
@@ -1019,18 +1019,16 @@
 reePane)
- %7B
 %0A       
@@ -1032,91 +1032,548 @@
     
-this.component = TestUtils.findRenderedDOMComponentWithClass(treePane, 'T
+    .findNode().assertValue('Default').assertIsExpanded().assertNumberOfChildren(1)%0A                .findChildNode('react-tree-pane').assertIsExpanded().assertNumberOfChildren(3)%0A                    .findChildNode('demo').assertIsExpanded().assertNumberOfChildren(2).end()%0A                    .findChildNode('src').assertIsExpanded().assertNumberOfChildren(1).end()%0A                    .findChildNode('test').assertIsExpanded().assertNumberOfChildren(1).end()%0A        ;%0A    %7D);%0A%7D);%0A%0A%0A%0A%0A%0Aclass TreePaneAsserter %7B%0A%0A    constructor(t
 reePane
-');
+) %7B
 %0A   
@@ -1614,230 +1614,623 @@
  %7D%0A%0A
-%0A    assertNumberOfChildren() %7B%0A        //expect(this.component.props.children.length).to.equal(3);%0A    %7D%0A%0A%0A    findChildren() %7B%0A        //return TestUtils.scryRenderedDOMComponentsWithClass(this.component, 'Node');%0A    %7D%0A
+    findNode() %7B%0A        return new NodeAsserter(this);%0A    %7D%0A%0A%7D%0A%0Aclass NodeAsserter %7B%0A    constructor(parent) %7B%0A        this.parent = parent;%0A    %7D%0A%0A    findCell() %7Breturn new CellAsserter(this) %7D%0A    assertValue() %7B return this; %7D%0A    assertIsExpanded() %7B return this; %7D%0A    assertIsCollapsed() %7B return this; %7D%0A    assertNumberOfChildren(expected) %7B return this; %7D%0A    findChildNode(value) %7B return new NodeAsserter(this) %7D%0A    end() %7B return this.parent; %7D%0A%7D%0A%0Aclass CellAsserter %7B%0A    constructor(parent) %7B%0A        this.parent = parent;%0A    %7D%0A    assertValue() %7B return this; %7D%0A    end() %7B return this.parent; %7D
 %0A%7D%0A%0A

test framework