`);
-
act(() => ReactDOM.unmountComponentAtNode(containerA));
expect(store).toMatchInlineSnapshot(``);
});
-
it('should not filter DOM nodes from the store tree', () => {
- const Grandparent = ({flip}) => (
-
- );
- const Parent = ({flip}) => (
-
- {flip ? 'foo' : null}
-
- {flip && [null, 'hello', 42]}
- {flip ? 'bar' : 'baz'}
-
- );
- const Child = () =>
Hi!
;
+ const Grandparent = ({flip}) =>
+ React.createElement(
+ 'div',
+ null,
+ React.createElement(
+ 'div',
+ null,
+ React.createElement(Parent, {
+ flip: flip,
+ }),
+ ),
+ React.createElement(Parent, {
+ flip: flip,
+ }),
+ React.createElement(Nothing, null),
+ );
+ const Parent = ({flip}) =>
+ React.createElement(
+ 'div',
+ null,
+ flip ? 'foo' : null,
+ React.createElement(Child, null),
+ flip && [null, 'hello', 42],
+ flip ? 'bar' : 'baz',
+ );
+ const Child = () => React.createElement('div', null, 'Hi!');
const Nothing = () => null;
-
const container = document.createElement('div');
act(() =>
- ReactDOM.render(
, container),
+ ReactDOM.render(
+ React.createElement(Grandparent, {
+ count: 4,
+ flip: false,
+ }),
+ container,
+ ),
);
expect(store).toMatchInlineSnapshot(`
[root]
@@ -244,9 +289,14 @@ describe('Store (legacy)', () => {
`);
-
act(() =>
- ReactDOM.render(, container),
+ ReactDOM.render(
+ React.createElement(Grandparent, {
+ count: 4,
+ flip: true,
+ }),
+ container,
+ ),
);
expect(store).toMatchInlineSnapshot(`
[root]
@@ -263,30 +313,37 @@ describe('Store (legacy)', () => {
`);
-
act(() => ReactDOM.unmountComponentAtNode(container));
expect(store).toMatchInlineSnapshot(``);
});
-
it('should support collapsing parts of the tree', () => {
- const Grandparent = ({count}) => (
-
- );
- const Parent = ({count}) => (
-
- {new Array(count).fill(true).map((_, index) => (
-
- ))}
-
- );
- const Child = () => Hi!
;
-
+ const Grandparent = ({count}) =>
+ React.createElement(
+ 'div',
+ null,
+ React.createElement(Parent, {
+ count: count,
+ }),
+ React.createElement(Parent, {
+ count: count,
+ }),
+ );
+ const Parent = ({count}) =>
+ React.createElement(
+ 'div',
+ null,
+ new Array(count).fill(true).map((_, index) =>
+ React.createElement(Child, {
+ key: index,
+ }),
+ ),
+ );
+ const Child = () => React.createElement('div', null, 'Hi!');
act(() =>
ReactDOM.render(
- ,
+ React.createElement(Grandparent, {
+ count: 2,
+ }),
document.createElement('div'),
),
);
@@ -307,11 +364,9 @@ describe('Store (legacy)', () => {
▾
`);
-
const grandparentID = store.getElementIDAtIndex(0);
const parentOneID = store.getElementIDAtIndex(2);
const parentTwoID = store.getElementIDAtIndex(8);
-
act(() => store.toggleIsCollapsed(parentOneID, true));
expect(store).toMatchInlineSnapshot(`
[root]
@@ -325,7 +380,6 @@ describe('Store (legacy)', () => {
▾
`);
-
act(() => store.toggleIsCollapsed(parentTwoID, true));
expect(store).toMatchInlineSnapshot(`
[root]
@@ -334,7 +388,6 @@ describe('Store (legacy)', () => {
▸
▸
`);
-
act(() => store.toggleIsCollapsed(parentOneID, false));
expect(store).toMatchInlineSnapshot(`
[root]
@@ -348,13 +401,11 @@ describe('Store (legacy)', () => {
▸
`);
-
act(() => store.toggleIsCollapsed(grandparentID, true));
expect(store).toMatchInlineSnapshot(`
[root]
▸
`);
-
act(() => store.toggleIsCollapsed(grandparentID, false));
expect(store).toMatchInlineSnapshot(`
[root]
@@ -369,18 +420,19 @@ describe('Store (legacy)', () => {
▸
`);
});
-
it('should support adding and removing children', () => {
- const Root = ({children}) => {children}
;
- const Component = () => ;
-
+ const Root = ({children}) => React.createElement('div', null, children);
+ const Component = () => React.createElement('div', null);
const container = document.createElement('div');
-
act(() =>
ReactDOM.render(
-
-
- ,
+ React.createElement(
+ Root,
+ null,
+ React.createElement(Component, {
+ key: 'a',
+ }),
+ ),
container,
),
);
@@ -391,13 +443,18 @@ describe('Store (legacy)', () => {
▾
`);
-
act(() =>
ReactDOM.render(
-
-
-
- ,
+ React.createElement(
+ Root,
+ null,
+ React.createElement(Component, {
+ key: 'a',
+ }),
+ React.createElement(Component, {
+ key: 'b',
+ }),
+ ),
container,
),
);
@@ -410,12 +467,15 @@ describe('Store (legacy)', () => {
▾
`);
-
act(() =>
ReactDOM.render(
-
-
- ,
+ React.createElement(
+ Root,
+ null,
+ React.createElement(Component, {
+ key: 'b',
+ }),
+ ),
container,
),
);
@@ -427,21 +487,34 @@ describe('Store (legacy)', () => {
`);
});
-
it('should support reordering of children', () => {
- const Root = ({children}) =>
{children}
;
- const Component = () =>
;
-
- const Foo = () =>
{[]}
;
- const Bar = () => (
-
{[, ]}
- );
- const foo =
;
- const bar =
;
-
+ const Root = ({children}) => React.createElement('div', null, children);
+ const Component = () => React.createElement('div', null);
+ const Foo = () =>
+ React.createElement('div', null, [
+ React.createElement(Component, {
+ key: '0',
+ }),
+ ]);
+ const Bar = () =>
+ React.createElement('div', null, [
+ React.createElement(Component, {
+ key: '0',
+ }),
+ React.createElement(Component, {
+ key: '1',
+ }),
+ ]);
+ const foo = React.createElement(Foo, {
+ key: 'foo',
+ });
+ const bar = React.createElement(Bar, {
+ key: 'bar',
+ });
const container = document.createElement('div');
-
- act(() => ReactDOM.render(
{[foo, bar]}, container));
+ act(() =>
+ ReactDOM.render(React.createElement(Root, null, [foo, bar]), container),
+ );
expect(store).toMatchInlineSnapshot(`
[root]
▾
@@ -457,8 +530,9 @@ describe('Store (legacy)', () => {
▾
`);
-
- act(() => ReactDOM.render(
{[bar, foo]}, container));
+ act(() =>
+ ReactDOM.render(React.createElement(Root, null, [bar, foo]), container),
+ );
expect(store).toMatchInlineSnapshot(`
[root]
▾
@@ -474,13 +548,11 @@ describe('Store (legacy)', () => {
▾
`);
-
act(() => store.toggleIsCollapsed(store.getElementIDAtIndex(0), true));
expect(store).toMatchInlineSnapshot(`
[root]
▸
`);
-
act(() => store.toggleIsCollapsed(store.getElementIDAtIndex(0), false));
expect(store).toMatchInlineSnapshot(`
[root]
@@ -499,30 +571,35 @@ describe('Store (legacy)', () => {
`);
});
});
-
describe('collapseNodesByDefault:true', () => {
beforeEach(() => {
store.collapseNodesByDefault = true;
});
-
it('should support mount and update operations', () => {
- const Parent = ({count}) => (
-
- {new Array(count).fill(true).map((_, index) => (
-
- ))}
-
- );
- const Child = () => Hi!
;
-
+ const Parent = ({count}) =>
+ React.createElement(
+ 'div',
+ null,
+ new Array(count).fill(true).map((_, index) =>
+ React.createElement(Child, {
+ key: index,
+ }),
+ ),
+ );
+ const Child = () => React.createElement('div', null, 'Hi!');
const container = document.createElement('div');
-
act(() =>
ReactDOM.render(
- ,
+ React.createElement(
+ 'div',
+ null,
+ React.createElement(Parent, {
+ count: 1,
+ }),
+ React.createElement(Parent, {
+ count: 3,
+ }),
+ ),
container,
),
);
@@ -530,13 +607,18 @@ describe('Store (legacy)', () => {
[root]
▸
`);
-
act(() =>
ReactDOM.render(
-
,
+ React.createElement(
+ 'div',
+ null,
+ React.createElement(Parent, {
+ count: 2,
+ }),
+ React.createElement(Parent, {
+ count: 1,
+ }),
+ ),
container,
),
);
@@ -544,27 +626,38 @@ describe('Store (legacy)', () => {
[root]
▸
`);
-
act(() => ReactDOM.unmountComponentAtNode(container));
expect(store).toMatchInlineSnapshot(``);
});
-
it('should support mount and update operations for multiple roots', () => {
- const Parent = ({count}) => (
-
- {new Array(count).fill(true).map((_, index) => (
-
- ))}
-
- );
- const Child = () =>
Hi!
;
-
+ const Parent = ({count}) =>
+ React.createElement(
+ 'div',
+ null,
+ new Array(count).fill(true).map((_, index) =>
+ React.createElement(Child, {
+ key: index,
+ }),
+ ),
+ );
+ const Child = () => React.createElement('div', null, 'Hi!');
const containerA = document.createElement('div');
const containerB = document.createElement('div');
-
act(() => {
- ReactDOM.render(
, containerA);
- ReactDOM.render(
, containerB);
+ ReactDOM.render(
+ React.createElement(Parent, {
+ key: 'A',
+ count: 3,
+ }),
+ containerA,
+ );
+ ReactDOM.render(
+ React.createElement(Parent, {
+ key: 'B',
+ count: 2,
+ }),
+ containerB,
+ );
});
expect(store).toMatchInlineSnapshot(`
[root]
@@ -572,10 +665,21 @@ describe('Store (legacy)', () => {
[root]
▸
`);
-
act(() => {
- ReactDOM.render(, containerA);
- ReactDOM.render(, containerB);
+ ReactDOM.render(
+ React.createElement(Parent, {
+ key: 'A',
+ count: 4,
+ }),
+ containerA,
+ );
+ ReactDOM.render(
+ React.createElement(Parent, {
+ key: 'B',
+ count: 1,
+ }),
+ containerB,
+ );
});
expect(store).toMatchInlineSnapshot(`
[root]
@@ -583,54 +687,62 @@ describe('Store (legacy)', () => {
[root]
▸
`);
-
act(() => ReactDOM.unmountComponentAtNode(containerB));
expect(store).toMatchInlineSnapshot(`
[root]
▸
`);
-
act(() => ReactDOM.unmountComponentAtNode(containerA));
expect(store).toMatchInlineSnapshot(``);
});
-
it('should not filter DOM nodes from the store tree', () => {
- const Grandparent = ({flip}) => (
-
- );
- const Parent = ({flip}) => (
-
- {flip ? 'foo' : null}
-
- {flip && [null, 'hello', 42]}
- {flip ? 'bar' : 'baz'}
-
- );
- const Child = () => Hi!
;
+ const Grandparent = ({flip}) =>
+ React.createElement(
+ 'div',
+ null,
+ React.createElement(
+ 'div',
+ null,
+ React.createElement(Parent, {
+ flip: flip,
+ }),
+ ),
+ React.createElement(Parent, {
+ flip: flip,
+ }),
+ React.createElement(Nothing, null),
+ );
+ const Parent = ({flip}) =>
+ React.createElement(
+ 'div',
+ null,
+ flip ? 'foo' : null,
+ React.createElement(Child, null),
+ flip && [null, 'hello', 42],
+ flip ? 'bar' : 'baz',
+ );
+ const Child = () => React.createElement('div', null, 'Hi!');
const Nothing = () => null;
-
const container = document.createElement('div');
act(() =>
- ReactDOM.render(, container),
+ ReactDOM.render(
+ React.createElement(Grandparent, {
+ count: 4,
+ flip: false,
+ }),
+ container,
+ ),
);
expect(store).toMatchInlineSnapshot(`
[root]
▸
`);
-
act(() => store.toggleIsCollapsed(store.getElementIDAtIndex(0), false));
expect(store).toMatchInlineSnapshot(`
[root]
▾
▸
`);
-
act(() => store.toggleIsCollapsed(store.getElementIDAtIndex(1), false));
expect(store).toMatchInlineSnapshot(`
[root]
@@ -640,9 +752,14 @@ describe('Store (legacy)', () => {
▸
`);
-
act(() =>
- ReactDOM.render(, container),
+ ReactDOM.render(
+ React.createElement(Grandparent, {
+ count: 4,
+ flip: true,
+ }),
+ container,
+ ),
);
expect(store).toMatchInlineSnapshot(`
[root]
@@ -652,30 +769,37 @@ describe('Store (legacy)', () => {
▸
`);
-
act(() => ReactDOM.unmountComponentAtNode(container));
expect(store).toMatchInlineSnapshot(``);
});
-
it('should support expanding parts of the tree', () => {
- const Grandparent = ({count}) => (
-
- );
- const Parent = ({count}) => (
-
- {new Array(count).fill(true).map((_, index) => (
-
- ))}
-
- );
- const Child = () => Hi!
;
-
+ const Grandparent = ({count}) =>
+ React.createElement(
+ 'div',
+ null,
+ React.createElement(Parent, {
+ count: count,
+ }),
+ React.createElement(Parent, {
+ count: count,
+ }),
+ );
+ const Parent = ({count}) =>
+ React.createElement(
+ 'div',
+ null,
+ new Array(count).fill(true).map((_, index) =>
+ React.createElement(Child, {
+ key: index,
+ }),
+ ),
+ );
+ const Child = () => React.createElement('div', null, 'Hi!');
act(() =>
ReactDOM.render(
- ,
+ React.createElement(Grandparent, {
+ count: 2,
+ }),
document.createElement('div'),
),
);
@@ -683,16 +807,13 @@ describe('Store (legacy)', () => {
[root]
▸
`);
-
const grandparentID = store.getElementIDAtIndex(0);
-
act(() => store.toggleIsCollapsed(grandparentID, false));
expect(store).toMatchInlineSnapshot(`
[root]
▾
▸
`);
-
const parentDivID = store.getElementIDAtIndex(1);
act(() => store.toggleIsCollapsed(parentDivID, false));
expect(store).toMatchInlineSnapshot(`
@@ -702,10 +823,8 @@ describe('Store (legacy)', () => {
▸
▸
`);
-
const parentOneID = store.getElementIDAtIndex(2);
const parentTwoID = store.getElementIDAtIndex(3);
-
act(() => store.toggleIsCollapsed(parentOneID, false));
expect(store).toMatchInlineSnapshot(`
[root]
@@ -715,7 +834,6 @@ describe('Store (legacy)', () => {
▸
▸
`);
-
act(() => store.toggleIsCollapsed(parentTwoID, false));
expect(store).toMatchInlineSnapshot(`
[root]
@@ -726,7 +844,6 @@ describe('Store (legacy)', () => {
▾
▸
`);
-
act(() => store.toggleIsCollapsed(parentOneID, true));
expect(store).toMatchInlineSnapshot(`
[root]
@@ -736,7 +853,6 @@ describe('Store (legacy)', () => {
▾
▸
`);
-
act(() => store.toggleIsCollapsed(parentTwoID, true));
expect(store).toMatchInlineSnapshot(`
[root]
@@ -745,7 +861,6 @@ describe('Store (legacy)', () => {
▸
▸
`);
-
act(() => store.toggleIsCollapsed(grandparentID, true));
expect(store).toMatchInlineSnapshot(`
[root]
@@ -760,24 +875,29 @@ describe('Store (legacy)', () => {
// one can use an older transform.
if (!require('shared/ReactFeatureFlags').enableRefAsProp) {
it('should support expanding deep parts of the tree', () => {
- const Wrapper = ({forwardedRef}) => (
-
- );
+ const Wrapper = ({forwardedRef}) =>
+ React.createElement(Nested, {
+ depth: 3,
+ forwardedRef: forwardedRef,
+ });
const Nested = ({depth, forwardedRef}) =>
- depth > 0 ? (
-
- ) : (
-
- );
-
+ depth > 0
+ ? React.createElement(Nested, {
+ depth: depth - 1,
+ forwardedRef: forwardedRef,
+ })
+ : React.createElement('div', {
+ ref: forwardedRef,
+ });
let ref = null;
const refSetter = value => {
ref = value;
};
-
act(() =>
ReactDOM.render(
- ,
+ React.createElement(Wrapper, {
+ forwardedRef: refSetter,
+ }),
document.createElement('div'),
),
);
@@ -785,9 +905,7 @@ describe('Store (legacy)', () => {
[root]
▸
`);
-
const deepestedNodeID = global.agent.getIDForNode(ref);
-
act(() => store.toggleIsCollapsed(deepestedNodeID, false));
expect(store).toMatchInlineSnapshot(`
[root]
@@ -798,15 +916,12 @@ describe('Store (legacy)', () => {
▾
`);
-
const rootID = store.getElementIDAtIndex(0);
-
act(() => store.toggleIsCollapsed(rootID, true));
expect(store).toMatchInlineSnapshot(`
[root]
▸
`);
-
act(() => store.toggleIsCollapsed(rootID, false));
expect(store).toMatchInlineSnapshot(`
[root]
@@ -817,16 +932,13 @@ describe('Store (legacy)', () => {
▾
`);
-
const id = store.getElementIDAtIndex(1);
-
act(() => store.toggleIsCollapsed(id, true));
expect(store).toMatchInlineSnapshot(`
[root]
▾
▸
`);
-
act(() => store.toggleIsCollapsed(id, false));
expect(store).toMatchInlineSnapshot(`
[root]
@@ -839,39 +951,51 @@ describe('Store (legacy)', () => {
`);
});
}
-
it('should support reordering of children', () => {
- const Root = ({children}) => {children}
;
- const Component = () => ;
-
- const Foo = () => {[]}
;
- const Bar = () => (
- {[, ]}
- );
- const foo = ;
- const bar = ;
-
+ const Root = ({children}) => React.createElement('div', null, children);
+ const Component = () => React.createElement('div', null);
+ const Foo = () =>
+ React.createElement('div', null, [
+ React.createElement(Component, {
+ key: '0',
+ }),
+ ]);
+ const Bar = () =>
+ React.createElement('div', null, [
+ React.createElement(Component, {
+ key: '0',
+ }),
+ React.createElement(Component, {
+ key: '1',
+ }),
+ ]);
+ const foo = React.createElement(Foo, {
+ key: 'foo',
+ });
+ const bar = React.createElement(Bar, {
+ key: 'bar',
+ });
const container = document.createElement('div');
-
- act(() => ReactDOM.render({[foo, bar]}, container));
+ act(() =>
+ ReactDOM.render(React.createElement(Root, null, [foo, bar]), container),
+ );
expect(store).toMatchInlineSnapshot(`
[root]
▸
`);
-
- act(() => ReactDOM.render({[bar, foo]}, container));
+ act(() =>
+ ReactDOM.render(React.createElement(Root, null, [bar, foo]), container),
+ );
expect(store).toMatchInlineSnapshot(`
[root]
▸
`);
-
act(() => store.toggleIsCollapsed(store.getElementIDAtIndex(0), false));
expect(store).toMatchInlineSnapshot(`
[root]
▾
▸
`);
-
act(() => store.toggleIsCollapsed(store.getElementIDAtIndex(1), false));
expect(store).toMatchInlineSnapshot(`
[root]
@@ -880,7 +1004,6 @@ describe('Store (legacy)', () => {
▸
▸
`);
-
act(() => {
store.toggleIsCollapsed(store.getElementIDAtIndex(3), false);
store.toggleIsCollapsed(store.getElementIDAtIndex(2), false);
@@ -894,7 +1017,6 @@ describe('Store (legacy)', () => {
▾
▸
`);
-
act(() => store.toggleIsCollapsed(store.getElementIDAtIndex(0), true));
expect(store).toMatchInlineSnapshot(`
[root]
@@ -902,14 +1024,11 @@ describe('Store (legacy)', () => {
`);
});
});
-
describe('StrictMode compliance', () => {
it('should mark all elements as strict mode compliant', () => {
const App = () => null;
-
const container = document.createElement('div');
- act(() => ReactDOM.render(
, container));
-
+ act(() => ReactDOM.render(React.createElement(App, null), container));
expect(store.getElementAtIndex(0).isStrictModeNonCompliant).toBe(false);
});
});