Skip to content

Commit

Permalink
feat(manager-react-components): udpate datagrid spec
Browse files Browse the repository at this point in the history
ref: MANAGER-15088

Signed-off-by: Alex Boungnaseng <[email protected]>
  • Loading branch information
aboungnaseng-ovhcloud committed Jan 28, 2025
1 parent a0b74df commit 76de7e4
Showing 1 changed file with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,21 @@ const sampleColumns = [
},
];

const columns = [
{
id: 'name',
cell: (name: string) => {
return <span>{name}</span>;
},
label: 'Name',
},
{
id: 'another-column',
label: 'test',
cell: () => <DataGridTextCell />,
},
];

const DatagridTest = ({
columns,

Check failure on line 65 in packages/manager-react-components/src/components/datagrid/datagrid.spec.tsx

View workflow job for this annotation

GitHub Actions / Lint Code Base

'columns' is already declared in the upper scope

Check failure on line 65 in packages/manager-react-components/src/components/datagrid/datagrid.spec.tsx

View workflow job for this annotation

GitHub Actions / Lint Code Base

'columns' is already declared in the upper scope
items,
Expand Down Expand Up @@ -232,7 +247,7 @@ it('should disable overflow of table', async () => {

it('should have the default number of loading row when isLoading is true and numberOfLoadingRows is not specified', async () => {
const { queryAllByTestId } = render(
<Datagrid columns={sampleColumns} items={[]} totalItems={0} isLoading />,
<Datagrid columns={columns} items={[]} totalItems={0} isLoading />,
);
expect(queryAllByTestId('loading-row').length).toBe(
defaultNumberOfLoadingRows,
Expand All @@ -243,7 +258,7 @@ it('should display the specified number of loading rows when isLoading is true',
const numberOfLoadingRows = 2;
const { queryAllByTestId } = render(
<Datagrid
columns={sampleColumns}
columns={columns}
items={[]}
totalItems={0}
numberOfLoadingRows={numberOfLoadingRows}
Expand All @@ -257,7 +272,7 @@ it('should display take the pageSize and not the default one as numberOfLoadingR
const pageSize = 10;
const { queryAllByTestId } = render(
<Datagrid
columns={sampleColumns}
columns={columns}
items={[]}
totalItems={0}
pagination={{ pageIndex: 0, pageSize }}
Expand All @@ -270,14 +285,16 @@ it('should display take the pageSize and not the default one as numberOfLoadingR
it('should set isLoading to load more button when isLoading is true', async () => {
const { getByTestId } = render(
<Datagrid
columns={sampleColumns}
columns={columns}
items={[]}
totalItems={0}
isLoading
hasNextPage
/>,
);
expect(getByTestId('load-more-btn')).toHaveAttribute('is-loading', 'true');
});

it('should disable overflow of table', async () => {
const { container } = render(
<DatagridTest
Expand Down

0 comments on commit 76de7e4

Please sign in to comment.