Make DataTable / DataInspector unit tests predictable
Summary: Having time / async / non-blocking behavior in components in unit tests is really annoying, as it makes unit tests async without an easy way to determine 'done'. This diff makes sure that DataTable & DataInspector don't break down their work in smaller tasks, but do everything block if they are running in a unit test. Reviewed By: nikoant Differential Revision: D28054487 fbshipit-source-id: 72c3b519e092ad69ed71eb1731e1fed80022f91f
This commit is contained in:
committed by
Facebook GitHub Bot
parent
39be769bab
commit
bbcb16d8fb
@@ -43,12 +43,7 @@ test('update and append', async () => {
|
||||
const ds = createTestDataSource();
|
||||
const ref = createRef<DataTableManager<Todo>>();
|
||||
const rendering = render(
|
||||
<DataTable
|
||||
dataSource={ds}
|
||||
columns={columns}
|
||||
tableManagerRef={ref}
|
||||
_testHeight={400}
|
||||
/>,
|
||||
<DataTable dataSource={ds} columns={columns} tableManagerRef={ref} />,
|
||||
);
|
||||
{
|
||||
const elem = await rendering.findAllByText('test DataTable');
|
||||
@@ -100,12 +95,7 @@ test('column visibility', async () => {
|
||||
const ds = createTestDataSource();
|
||||
const ref = createRef<DataTableManager<Todo>>();
|
||||
const rendering = render(
|
||||
<DataTable
|
||||
dataSource={ds}
|
||||
columns={columns}
|
||||
tableManagerRef={ref}
|
||||
_testHeight={400}
|
||||
/>,
|
||||
<DataTable dataSource={ds} columns={columns} tableManagerRef={ref} />,
|
||||
);
|
||||
{
|
||||
const elem = await rendering.findAllByText('test DataTable');
|
||||
@@ -176,12 +166,7 @@ test('sorting', async () => {
|
||||
});
|
||||
const ref = createRef<DataTableManager<Todo>>();
|
||||
const rendering = render(
|
||||
<DataTable
|
||||
dataSource={ds}
|
||||
columns={columns}
|
||||
tableManagerRef={ref}
|
||||
_testHeight={400}
|
||||
/>,
|
||||
<DataTable dataSource={ds} columns={columns} tableManagerRef={ref} />,
|
||||
);
|
||||
// insertion order
|
||||
{
|
||||
@@ -256,7 +241,6 @@ test('search', async () => {
|
||||
columns={columns}
|
||||
tableManagerRef={ref}
|
||||
extraActions={<Button>Test Button</Button>}
|
||||
_testHeight={400}
|
||||
/>,
|
||||
);
|
||||
{
|
||||
@@ -540,7 +524,6 @@ test('onSelect callback fires, and in order', () => {
|
||||
dataSource={ds}
|
||||
columns={columns}
|
||||
tableManagerRef={ref}
|
||||
_testHeight={400}
|
||||
onSelect={(item, items) => {
|
||||
events.push([item, items]);
|
||||
}}
|
||||
@@ -592,7 +575,6 @@ test('selection always has the latest state', () => {
|
||||
dataSource={ds}
|
||||
columns={columns}
|
||||
tableManagerRef={ref}
|
||||
_testHeight={400}
|
||||
onSelect={(item, items) => {
|
||||
events.push([item, items]);
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user