mirror of
https://github.com/hanzoai/react.git
synced 2026-09-24 17:02:27 +00:00
Added separate mount+update tests
This commit is contained in:
@@ -1,23 +1,51 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Store should initialize a multiple root tree 1`] = `
|
||||
[root]
|
||||
▾ <Parent>
|
||||
<Child key="one">
|
||||
<Child key="two">
|
||||
[root]
|
||||
▾ <Parent>
|
||||
<Child key="one">
|
||||
<Child key="two">
|
||||
`;
|
||||
|
||||
exports[`Store should initialize a simple tree 1`] = `
|
||||
exports[`Store should support mount and update operations 1`] = `
|
||||
[root]
|
||||
▾ <Grandparent>
|
||||
▾ <Parent>
|
||||
<Child key="one">
|
||||
<Child key="two">
|
||||
<Child key="0">
|
||||
<Child key="1">
|
||||
<Child key="2">
|
||||
<Child key="3">
|
||||
▾ <Parent>
|
||||
<Child key="one">
|
||||
<Child key="two">
|
||||
<Child key="0">
|
||||
<Child key="1">
|
||||
<Child key="2">
|
||||
<Child key="3">
|
||||
`;
|
||||
|
||||
exports[`Store should support mount and update operations 2`] = `
|
||||
[root]
|
||||
▾ <Grandparent>
|
||||
▾ <Parent>
|
||||
<Child key="0">
|
||||
<Child key="1">
|
||||
▾ <Parent>
|
||||
<Child key="0">
|
||||
<Child key="1">
|
||||
`;
|
||||
|
||||
exports[`Store should support mount and update operations for multiple roots 1`] = `
|
||||
[root]
|
||||
▾ <Parent>
|
||||
<Child key="0">
|
||||
<Child key="1">
|
||||
<Child key="2">
|
||||
[root]
|
||||
▾ <Parent>
|
||||
<Child key="0">
|
||||
<Child key="1">
|
||||
`;
|
||||
|
||||
exports[`Store should support mount and update operations for multiple roots 2`] = `
|
||||
[root]
|
||||
▾ <Parent>
|
||||
<Child key="0">
|
||||
<Child key="1">
|
||||
<Child key="2">
|
||||
<Child key="3">
|
||||
[root]
|
||||
▾ <Parent>
|
||||
<Child key="0">
|
||||
`;
|
||||
|
||||
+30
-10
@@ -12,29 +12,49 @@ describe('Store', () => {
|
||||
ReactDOM = require('react-dom');
|
||||
});
|
||||
|
||||
it('should initialize a simple tree', () => {
|
||||
const Grandparent = () => (
|
||||
it('should support mount and update operations', () => {
|
||||
const Grandparent = ({ count }) => (
|
||||
<React.Fragment>
|
||||
<Parent />
|
||||
<Parent />
|
||||
<Parent count={count} />
|
||||
<Parent count={count} />
|
||||
</React.Fragment>
|
||||
);
|
||||
const Parent = () => [<Child key="one" />, <Child key="two" />];
|
||||
const Parent = ({ count }) =>
|
||||
new Array(count).fill(true).map((_, index) => <Child key={index} />);
|
||||
const Child = () => <div>Hi!</div>;
|
||||
|
||||
ReactDOM.render(<Grandparent />, document.createElement('div'));
|
||||
const container = document.createElement('div');
|
||||
|
||||
ReactDOM.render(<Grandparent count={4} />, container);
|
||||
|
||||
jest.runAllTimers(); // Flush Bridge operations
|
||||
|
||||
expect(store).toMatchSnapshot();
|
||||
|
||||
ReactDOM.render(<Grandparent count={2} />, container);
|
||||
|
||||
jest.runAllTimers(); // Flush Bridge operations
|
||||
|
||||
expect(store).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should initialize a multiple root tree', () => {
|
||||
const Parent = () => [<Child key="one" />, <Child key="two" />];
|
||||
it('should support mount and update operations for multiple roots', () => {
|
||||
const Parent = ({ count }) =>
|
||||
new Array(count).fill(true).map((_, index) => <Child key={index} />);
|
||||
const Child = () => <div>Hi!</div>;
|
||||
|
||||
ReactDOM.render(<Parent />, document.createElement('div'));
|
||||
ReactDOM.render(<Parent />, document.createElement('div'));
|
||||
const containerA = document.createElement('div');
|
||||
const containerB = document.createElement('div');
|
||||
|
||||
ReactDOM.render(<Parent count={3} />, containerA);
|
||||
ReactDOM.render(<Parent count={2} />, containerB);
|
||||
|
||||
jest.runAllTimers(); // Flush Bridge operations
|
||||
|
||||
expect(store).toMatchSnapshot();
|
||||
|
||||
ReactDOM.render(<Parent count={4} />, containerA);
|
||||
ReactDOM.render(<Parent count={1} />, containerB);
|
||||
|
||||
jest.runAllTimers(); // Flush Bridge operations
|
||||
|
||||
|
||||
Reference in New Issue
Block a user