From c9bf853cfd41bcafed81e93591cf7b6593cf45f4 Mon Sep 17 00:00:00 2001 From: asimonok Date: Tue, 7 Nov 2023 08:43:51 +0300 Subject: [PATCH] Add test for always visible search --- src/components/Table/Table.test.tsx | 36 +++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/src/components/Table/Table.test.tsx b/src/components/Table/Table.test.tsx index e3b0fd4..c070de5 100644 --- a/src/components/Table/Table.test.tsx +++ b/src/components/Table/Table.test.tsx @@ -5,6 +5,11 @@ import { getJestSelectors } from '@volkovlabs/jest-selectors'; import { TestIds } from '../../constants'; import { Table } from './Table'; +/** + * Props + */ +type Props = React.ComponentProps; + /** * Test Ids only for tests */ @@ -32,7 +37,7 @@ describe('Table', () => { * Get Tested Component * @param props */ - const getComponent = (props: any) => ; + const getComponent = (props: Partial) => ; /** * Selectors @@ -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 @@ -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 {value}; + }, + }, + ], + 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({