Professional Documents
Culture Documents
Storeowners Test
Storeowners Test
beforeEach(() => {
store = global.store;
store.collapseNodesByDefault = false;
React = require('react');
function getFormattedOwnersList(elementID) {
const ownersList = store.getOwnersListForElement(elementID);
return printOwnersList(ownersList);
}
it('should show the proper owners list order and contents after insertions and
deletions', () => {
const Root = ({includeDirect, includeIndirect}) => (
<div>
{includeDirect ? <Leaf /> : null}
{includeIndirect ? (
<Intermediate>
<Leaf />
</Intermediate>
) : null}
</div>
);
const Wrapper = ({children}) => children;
const Leaf = () => <div>Leaf</div>;
const Intermediate = ({children}) => <Wrapper>{children}</Wrapper>;
act(() =>
legacyRender(
<Root includeDirect={false} includeIndirect={true} />,
container,
),
);
act(() =>
legacyRender(
<Root includeDirect={true} includeIndirect={true} />,
container,
),
);
expect(store).toMatchInlineSnapshot(`
[root]
▾ <Root>
<Leaf>
▾ <Intermediate>
▾ <Wrapper>
<Leaf>
`);
expect(getFormattedOwnersList(rootID)).toMatchInlineSnapshot(`
" ▾ <Root>
<Leaf>
▾ <Intermediate>
<Leaf>"
`);
act(() =>
legacyRender(
<Root includeDirect={true} includeIndirect={false} />,
container,
),
);
expect(store).toMatchInlineSnapshot(`
[root]
▾ <Root>
<Leaf>
`);
expect(getFormattedOwnersList(rootID)).toMatchInlineSnapshot(`
" ▾ <Root>
<Leaf>"
`);
act(() =>
legacyRender(
<Root includeDirect={false} includeIndirect={false} />,
container,
),
);
expect(store).toMatchInlineSnapshot(`
[root]
<Root>
`);
expect(getFormattedOwnersList(rootID)).toMatchInlineSnapshot(
`" <Root>"`,
);
});
it('should show the proper owners list ordering after reordered children', () =>
{
const Root = ({ascending}) =>
ascending
? [<Leaf key="A" />, <Leaf key="B" />, <Leaf key="C" />]
: [<Leaf key="C" />, <Leaf key="B" />, <Leaf key="A" />];
const Leaf = () => <div>Leaf</div>;