Skip to content

Commit

Permalink
Add test for always visible search
Browse files Browse the repository at this point in the history
  • Loading branch information
asimonok committed Nov 7, 2023
1 parent 8727d17 commit c9bf853
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions src/components/Table/Table.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import { getJestSelectors } from '@volkovlabs/jest-selectors';
import { TestIds } from '../../constants';
import { Table } from './Table';

/**
* Props
*/
type Props = React.ComponentProps<typeof Table>;

/**
* Test Ids only for tests
*/
Expand Down Expand Up @@ -32,7 +37,7 @@ describe('Table', () => {
* Get Tested Component
* @param props
*/
const getComponent = (props: any) => <Wrapper {...props} />;
const getComponent = (props: Partial<Props>) => <Wrapper {...props} />;

/**
* Selectors
Expand Down Expand Up @@ -78,7 +83,7 @@ describe('Table', () => {
},
];

render(getComponent({ data, columns, getSubRows: (row: any) => row.children }));
render(getComponent({ data, columns: columns as any, getSubRows: (row: any) => row.children }));

/**
* Check first row with sub rows
Expand Down Expand Up @@ -152,6 +157,33 @@ describe('Table', () => {
expect(selectors.cell(true, 'device2', 0)).not.toBeInTheDocument();
});

it('Should always show value filter', async () => {
render(
getComponent({
showHeader: true,
columns: [
{
id: 'value',
header: 'cell header',
accessorKey: 'value',
enableColumnFilter: true,
cell: ({ getValue, row }: any) => {
const value = getValue() as string;
return <span data-testid={InTestIds.cell(value, row.depth)}>{value}</span>;
},
},
],
data: [{ value: 'device1' }, { value: 'device2' }],
alwaysVisibleFilter: true,
})
);

/**
* Check Filter Content Presence
*/
expect(selectors.fieldFilterValue()).toBeInTheDocument();
});

it('Should show value sorting', async () => {
const { container } = render(
getComponent({
Expand Down

0 comments on commit c9bf853

Please sign in to comment.