Skip to content

Commit

Permalink
Add missing regression/confidence test for setSelection API
Browse files Browse the repository at this point in the history
  • Loading branch information
cee-chen committed Oct 30, 2023
1 parent ec7863c commit fdfe1bb
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/components/basic_table/basic_table.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import React from 'react';
import { act } from '@testing-library/react';
import { render, screen } from '../../test/rtl';
import { requiredProps } from '../../test';
import { shouldRenderCustomStyles } from '../../test/internal';
Expand Down Expand Up @@ -459,6 +460,34 @@ describe('EuiBasicTable', () => {
expect(onSelectionChange).toHaveBeenCalledWith([]);
expect(container.querySelectorAll('[checked]')).toHaveLength(0);
});

// TODO: Delete this test once deprecated API is removed
test('deprecated setSelection ref API', () => {
const props = {
items: basicItems,
columns: basicColumns,
itemId: 'id',
selection: {
onSelectionChange: () => {},
},
};

let classRef: EuiBasicTable | null;
render(
<EuiBasicTable
{...props}
ref={(ref) => {
classRef = ref;
}}
/>
);
expect(getCheckboxAt(1).checked).toBeFalsy();

act(() => {
classRef!.setSelection([basicItems[0]]);
});
expect(getCheckboxAt(1).checked).toBeTruthy();
});
});

test('footers', () => {
Expand Down

0 comments on commit fdfe1bb

Please sign in to comment.