import React from "dist/React";
import getTestDocument from "./getTestDocument";
import ReactTestUtils from "lib/ReactTestUtils";

import ReactDOMServer from "dist/ReactDOMServer";
//https://github.com/facebook/react/blob/master/src/isomorphic/children/__tests__/ReactChildren-test.js
var ReactDOM = window.ReactDOM || React;

describe("ReactComponent", function() {
    this.timeout(200000);

    it("should allow key property to express identity", () => {
        var node;
        var Component = props => (
            <div ref={c => (node = c)}>
                <div key={props.swap ? "banana" : "apple"} />
                <div key={props.swap ? "apple" : "banana"} />
            </div>
        );

        var container = document.createElement("div");
        ReactDOM.render(<Component />, container);
        var origChildren = Array.from(node.childNodes);
        ReactDOM.render(<Component swap={true} />, container);
        var newChildren = Array.from(node.childNodes);
        expect(origChildren[0]).toBe(newChildren[1]);
        expect(origChildren[1]).toBe(newChildren[0]);
    });
});