mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Forgot to mark test as experimental (#17391)
This commit is contained in:
@@ -19,7 +19,7 @@ let useState;
|
||||
let useTransition;
|
||||
let act;
|
||||
|
||||
describe('ReactHooksWithNoopRenderer', () => {
|
||||
describe('ReactTransition', () => {
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
|
||||
@@ -59,44 +59,47 @@ describe('ReactHooksWithNoopRenderer', () => {
|
||||
return Component;
|
||||
}
|
||||
|
||||
it('isPending works even if called from outside an input event', async () => {
|
||||
const Async = createAsyncText('Async');
|
||||
let start;
|
||||
function App() {
|
||||
const [show, setShow] = useState(false);
|
||||
const [startTransition, isPending] = useTransition();
|
||||
start = () => startTransition(() => setShow(true));
|
||||
return (
|
||||
<Suspense fallback={<Text text="Loading..." />}>
|
||||
{isPending ? <Text text="Pending..." /> : null}
|
||||
{show ? <Async /> : <Text text="(empty)" />}
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
it.experimental(
|
||||
'isPending works even if called from outside an input event',
|
||||
async () => {
|
||||
const Async = createAsyncText('Async');
|
||||
let start;
|
||||
function App() {
|
||||
const [show, setShow] = useState(false);
|
||||
const [startTransition, isPending] = useTransition();
|
||||
start = () => startTransition(() => setShow(true));
|
||||
return (
|
||||
<Suspense fallback={<Text text="Loading..." />}>
|
||||
{isPending ? <Text text="Pending..." /> : null}
|
||||
{show ? <Async /> : <Text text="(empty)" />}
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
|
||||
const root = ReactNoop.createRoot();
|
||||
const root = ReactNoop.createRoot();
|
||||
|
||||
await act(async () => {
|
||||
root.render(<App />);
|
||||
});
|
||||
expect(Scheduler).toHaveYielded(['(empty)']);
|
||||
expect(root).toMatchRenderedOutput('(empty)');
|
||||
await act(async () => {
|
||||
root.render(<App />);
|
||||
});
|
||||
expect(Scheduler).toHaveYielded(['(empty)']);
|
||||
expect(root).toMatchRenderedOutput('(empty)');
|
||||
|
||||
await act(async () => {
|
||||
start();
|
||||
await act(async () => {
|
||||
start();
|
||||
|
||||
expect(Scheduler).toFlushAndYield([
|
||||
'Pending...',
|
||||
'(empty)',
|
||||
'Suspend! [Async]',
|
||||
'Loading...',
|
||||
]);
|
||||
expect(Scheduler).toFlushAndYield([
|
||||
'Pending...',
|
||||
'(empty)',
|
||||
'Suspend! [Async]',
|
||||
'Loading...',
|
||||
]);
|
||||
|
||||
expect(root).toMatchRenderedOutput('Pending...(empty)');
|
||||
expect(root).toMatchRenderedOutput('Pending...(empty)');
|
||||
|
||||
await Async.resolve();
|
||||
});
|
||||
expect(Scheduler).toHaveYielded(['Async']);
|
||||
expect(root).toMatchRenderedOutput('Async');
|
||||
});
|
||||
await Async.resolve();
|
||||
});
|
||||
expect(Scheduler).toHaveYielded(['Async']);
|
||||
expect(root).toMatchRenderedOutput('Async');
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user