diff --git a/packages/react-native/Libraries/Lists/__tests__/FlatList-itest.js b/packages/react-native/Libraries/Lists/__tests__/FlatList-itest.js new file mode 100644 index 00000000000..e24f8011639 --- /dev/null +++ b/packages/react-native/Libraries/Lists/__tests__/FlatList-itest.js @@ -0,0 +1,148 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict-local + * @format + */ + +import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment'; + +import * as Fantom from '@react-native/fantom'; +import * as React from 'react'; +import {FlatList, Text} from 'react-native'; + +describe('', () => { + describe('props', () => { + describe('data & renderItem', () => { + const root = Fantom.createRoot(); + it('List is rendered as expected', () => { + Fantom.runTask(() => { + root.render( + {item.title}} + />, + ); + }); + + expect( + JSON.stringify(root.getRenderedOutput({props: []}).toJSX()), + ).toEqual( + JSON.stringify( + + + Title Text + Title Text 2 + + , + ), + ); + }); + }); + + describe('inverted', () => { + it('changes prop isInvertedVirtualizedList which gets propagated to mounting layer', () => { + const root = Fantom.createRoot(); + Fantom.runTask(() => { + root.render(); + }); + + expect( + root + .getRenderedOutput({ + props: ['inverted', 'isInvertedVirtualizedList'], + }) + .toJSX(), + ).toEqual( + + + , + ); + }); + + it('default value is false', () => { + const root = Fantom.createRoot(); + Fantom.runTask(() => { + root.render(); + }); + + expect( + root + .getRenderedOutput({ + props: ['inverted', 'isInvertedVirtualizedList'], + }) + .toJSX(), + ).toEqual( + + + , + ); + }); + }); + }); + + describe('props inherited from ScrollView', () => { + describe('horizontal', () => { + const root = Fantom.createRoot(); + it('is propagated to the mounting layer', () => { + Fantom.runTask(() => { + root.render(); + }); + + expect(root.getRenderedOutput({props: ['horizontal']}).toJSX()).toEqual( + + + , + ); + }); + + it('default value is false', () => { + Fantom.runTask(() => { + root.render(); + }); + + expect(root.getRenderedOutput({props: ['horizontal']}).toJSX()).toEqual( + + + , + ); + }); + }); + + describe('scrollEnabled', () => { + const root = Fantom.createRoot(); + it('default value is true', () => { + Fantom.runTask(() => { + root.render(); + }); + + expect( + root.getRenderedOutput({props: ['scrollEnabled']}).toJSX(), + ).toEqual( + + + , + ); + }); + it('is propagated to the mounting layer', () => { + Fantom.runTask(() => { + root.render(); + }); + + expect( + root.getRenderedOutput({props: ['scrollEnabled']}).toJSX(), + ).toEqual( + + + , + ); + }); + }); + }); +}); diff --git a/packages/react-native/ReactCommon/react/renderer/components/scrollview/BaseScrollViewProps.cpp b/packages/react-native/ReactCommon/react/renderer/components/scrollview/BaseScrollViewProps.cpp index a62c9f1bc99..a683cb87f82 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/scrollview/BaseScrollViewProps.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/scrollview/BaseScrollViewProps.cpp @@ -558,7 +558,7 @@ SharedDebugStringConvertibleList BaseScrollViewProps::getDebugProps() const { "snapToEnd", snapToEnd, defaultScrollViewProps.snapToEnd), debugStringConvertibleItem( "isInvertedVirtualizedList", - snapToEnd, + isInvertedVirtualizedList, defaultScrollViewProps.isInvertedVirtualizedList)}; } #endif