Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions packages/react-client/src/__tests__/ReactFlight-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,25 @@ describe('ReactFlight', () => {
});
});

it('can transport cyclic arrays', async () => {
function ComponentClient({prop, obj}) {
expect(prop[1]).toBe(prop);
expect(prop[0]).toBe(obj);
}
const Component = clientReference(ComponentClient);

const obj = {};
const cyclic = [obj];
cyclic[1] = cyclic;
const model = <Component prop={cyclic} obj={obj} />;

const transport = ReactNoopFlightServer.render(model);

await act(async () => {
ReactNoop.render(await ReactNoopFlightClient.read(transport));
});
});

it('can render a lazy component as a shared component on the server', async () => {
function SharedComponent({text}) {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,17 @@ describe('ReactFlightDOMReply', () => {
expect(root.prop.obj).toBe(root.prop);
});

it('can transport cyclic arrays', async () => {
const obj = {};
const cyclic = [obj];
cyclic[1] = cyclic;

const body = await ReactServerDOMClient.encodeReply({prop: cyclic, obj});
const root = await ReactServerDOMServer.decodeReply(body, webpackServerMap);
expect(root.prop[1]).toBe(root.prop);
expect(root.prop[0]).toBe(root.obj);
});

it('can abort an unresolved model and get the partial result', async () => {
const promise = new Promise(r => {});
const controller = new AbortController();
Expand Down
Loading