import PropTypes from '../../lib/ReactPropTypes';
import ReactTestUtils from "../../lib/ReactTestUtils";
import React from '../../src/May';
import { render, unmountComponentAtNode, findDOMNode } from '../../src/may-dom/MayDom';
import { shallowCompare } from '../../src/PureComponent';
var ReactDOM = {
render: render,
unmountComponentAtNode: unmountComponentAtNode,
findDOMNode: findDOMNode
}
React.render = render;
// import React from "../../dist/ReactANU";
// var ReactDOM = React;
// var ReactTestUtils = {
// renderIntoDocument: function (element) {
// var div = document.createElement("div");
// return React.render(element, div);
// }
// };
//https://github.com/facebook/react/blob/master/src/isomorphic/children/__tests__/ReactChildren-test.js
describe("ReactIdentity", function () {
// this.timeout(200000);
it("should allow key property to express identity", () => {
var node;
var Component = props => (
{
var instance0 =
;
var instance1 =
;
var instance2 =
;
class TestComponent extends React.Component {
render() {
return (
{instance2}
{this.props.children[0]}
{this.props.children[1]}
);
}
}
class TestContainer extends React.Component {
render() {
return
{instance0}{instance1};
}
}
expect(function() {
ReactTestUtils.renderIntoDocument(
);
}).not.toThrow();
});
it("should let nested restructures retain their uniqueness", () => {
var instance0 =
;
var instance1 =
;
var instance2 =
;
class TestComponent extends React.Component {
render() {
return (
{instance2}
{this.props.children[0]}
{this.props.children[1]}
);
}
}
class TestContainer extends React.Component {
render() {
return (
{instance0}{instance1}
);
}
}
expect(function() {
ReactTestUtils.renderIntoDocument(
);
}).not.toThrow();
});
it("should let text nodes retain their uniqueness", () => {
class TestComponent extends React.Component {
render() {
return
{this.props.children}
;
}
}
class TestContainer extends React.Component {
render() {
return (
{"second"}
);
}
}
expect(function() {
ReactTestUtils.renderIntoDocument(
);
}).not.toThrow();
});
it('should retain key during updates in composite components', () => {
class TestComponent extends React.Component {
render() {
return
{this.props.children}
;
}
}
class TestContainer extends React.Component {
state = {swapped: false};
swap = () => {
this.setState({swapped: true});
};
render() {
return (
{this.state.swapped ? this.props.second : this.props.first}
{this.state.swapped ? this.props.first : this.props.second}
);
}
}
var instance0 =
;
var instance1 =
;
var wrapped =
;
wrapped = ReactDOM.render(wrapped, document.createElement('div'));
var div = ReactDOM.findDOMNode(wrapped);
var beforeA = div.childNodes[0];
var beforeB = div.childNodes[1];
wrapped.swap();
var afterA = div.childNodes[1];
var afterB = div.childNodes[0];
expect(beforeA).toBe(afterA);
expect(beforeB).toBe(afterB);
});
it('should not allow implicit and explicit keys to collide', () => {
var component = (
);
expect(function() {
ReactTestUtils.renderIntoDocument(component);
}).not.toThrow();
});
});