Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage committed Jun 12, 2024
1 parent e4694c5 commit a9a89d0
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions packages/react-client/src/__tests__/ReactFlight-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2565,6 +2565,50 @@ describe('ReactFlight', () => {
);
});

it('can change the environment name inside a component', async () => {
let env = 'A';
function Component(props) {
env = 'B';
return <div>hi</div>;
}

const transport = ReactNoopFlightServer.render(
{
greeting: <Component />,
},
{
environmentName() {
return env;
},
},
);

await act(async () => {
const rootModel = await ReactNoopFlightClient.read(transport);
const greeting = rootModel.greeting;
expect(getDebugInfo(greeting)).toEqual(
__DEV__
? [
{
name: 'Component',
env: 'A',
owner: null,
stack: gate(flag => flag.enableOwnerStacks)
? ' in Object.<anonymous> (at **)'
: undefined,
},
{
env: 'B',
},
]
: undefined,
);
ReactNoop.render(greeting);
});

expect(ReactNoop).toMatchRenderedOutput(<div>hi</div>);
});

// @gate enableServerComponentLogs && __DEV__
it('replays logs, but not onError logs', async () => {
function foo() {
Expand Down

0 comments on commit a9a89d0

Please sign in to comment.