Skip to content

Commit 6ff0af1

Browse files
committed
Add tests for ReactFlightServerTemporaryReferences to validate temporary reference async retrieval
1 parent d9135f0 commit 6ff0af1

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @emails react-core
8+
* @jest-environment node
9+
*/
10+
11+
'use strict';
12+
13+
let ReactFlightServerTemporaryReferences;
14+
15+
describe('ReactFlightServerTemporaryReferences', () => {
16+
beforeEach(() => {
17+
jest.resetModules();
18+
ReactFlightServerTemporaryReferences = require('react-server/src/ReactFlightServerTemporaryReferences');
19+
});
20+
21+
it('can return a temporary reference from an async function', async () => {
22+
const temporaryReferenceSet =
23+
ReactFlightServerTemporaryReferences.createTemporaryReferenceSet();
24+
const temporaryReference =
25+
ReactFlightServerTemporaryReferences.createTemporaryReference(
26+
temporaryReferenceSet,
27+
'test',
28+
);
29+
30+
async function foo() {
31+
return temporaryReference;
32+
}
33+
34+
await expect(foo()).resolves.toBe(temporaryReference);
35+
});
36+
});

0 commit comments

Comments
 (0)