Migrate SectionList-test to async jest/renderer create abstraction (#44999)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44999

Use `act`-wrapped abstraction for test rendering in preparation for this becoming mandatory.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D58651098

fbshipit-source-id: d797c792b1f6ac155f02951a8264cf0631961d83
This commit is contained in:
Rob Hogan
2024-06-16 16:55:21 -07:00
committed by Facebook GitHub Bot
parent b24cf4f54c
commit 9435097b16
@@ -10,13 +10,13 @@
'use strict';
import {create} from '../../../jest/renderer';
import SectionList from '../SectionList';
import * as React from 'react';
import ReactTestRenderer from 'react-test-renderer';
describe('SectionList', () => {
it('renders empty list', () => {
const component = ReactTestRenderer.create(
it('renders empty list', async () => {
const component = await create(
<SectionList
sections={[]}
renderItem={({item}) => <item v={item.key} />}
@@ -24,8 +24,8 @@ describe('SectionList', () => {
);
expect(component).toMatchSnapshot();
});
it('rendering empty section headers is fine', () => {
const component = ReactTestRenderer.create(
it('rendering empty section headers is fine', async () => {
const component = await create(
<SectionList
sections={[{key: 's1', data: [{key: 'i1'}, {key: 'i2'}]}]}
renderItem={({item}) => <item v={item.key} />}
@@ -34,8 +34,8 @@ describe('SectionList', () => {
);
expect(component).toMatchSnapshot();
});
it('renders all the bells and whistles', () => {
const component = ReactTestRenderer.create(
it('renders all the bells and whistles', async () => {
const component = await create(
<SectionList
initialNumToRender={Infinity}
ItemSeparatorComponent={props => (
@@ -75,8 +75,8 @@ describe('SectionList', () => {
);
expect(component).toMatchSnapshot();
});
it('renders a footer when there is no data', () => {
const component = ReactTestRenderer.create(
it('renders a footer when there is no data', async () => {
const component = await create(
<SectionList
sections={[{key: 's1', data: []}]}
renderItem={({item}) => <item v={item.key} />}
@@ -86,8 +86,8 @@ describe('SectionList', () => {
);
expect(component).toMatchSnapshot();
});
it('renders a footer when there is no data and no header', () => {
const component = ReactTestRenderer.create(
it('renders a footer when there is no data and no header', async () => {
const component = await create(
<SectionList
sections={[{key: 's1', data: []}]}
renderItem={({item}) => <item v={item.key} />}