Skip to content

Commit

Permalink
[Flight] Add gated test for desired behavior for undefined props
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Mar 25, 2023
1 parent b447234 commit 67c618f
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions packages/react-client/src/__tests__/ReactFlight-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,23 +213,38 @@ describe('ReactFlight', () => {
expect(ReactNoop).toMatchRenderedOutput(null);
});

it('can transport undefined object values', async () => {
function ComponentClient(props) {
// @gate FIXME
it('should transport undefined object values', async () => {
function ServerComponent(props) {
return 'prop' in props
? `\`prop\` in props as '${props.prop}'`
: '`prop` not in props';
}
const Component = clientReference(ComponentClient);
const ClientComponent = clientReference(ServerComponent);

const model = <Component prop={undefined} />;
const model = (
<>
<div>
Server: <ServerComponent prop={undefined} />
</div>
<div>
Client: <ClientComponent prop={undefined} />
</div>
</>
);

const transport = ReactNoopFlightServer.render(model);

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

expect(ReactNoop).toMatchRenderedOutput("`prop` in props as 'undefined'");
expect(ReactNoop).toMatchRenderedOutput(
<>
<div>Server: `prop` in props as 'undefined'</div>
<div>Client: `prop` in props as 'undefined'</div>
</>,
);
});

it('can render an empty fragment', async () => {
Expand Down

0 comments on commit 67c618f

Please sign in to comment.