From 41549d378047beb0e6cb9e58171caa4e2d14a1a7 Mon Sep 17 00:00:00 2001 From: Samuel Gomez Date: Sun, 21 Jan 2024 21:20:15 +0100 Subject: [PATCH] fix(table): cover and clean --- scripts/clean.js | 2 -- .../Table/Headers/Header/__tests__/Header.test.tsx | 14 ++++++++++++++ .../testsUtils/sharedScenarios/table/utils.ts | 5 ++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/scripts/clean.js b/scripts/clean.js index 36c4dd0a..bbdb399b 100644 --- a/scripts/clean.js +++ b/scripts/clean.js @@ -30,13 +30,11 @@ const pathsDelete = [ './src/pages/Home/Galleries', './src/assets', './src/shared/testsUtils/clearString.ts', - './src/shared/toolkit.ts', './src/shared/components/LiveCode', './src/shared/components/Cards', './src/shared/components/LazyImage', './src/shared/components/DownloadLink', './src/shared/components/Editor', - './src/shared/components/testsUtils/clearString.ts', './src/pages/Demos', './features/Demos', 'renovate.json', diff --git a/src/shared/components/Table/Headers/Header/__tests__/Header.test.tsx b/src/shared/components/Table/Headers/Header/__tests__/Header.test.tsx index 518d62bc..8dd814c5 100644 --- a/src/shared/components/Table/Headers/Header/__tests__/Header.test.tsx +++ b/src/shared/components/Table/Headers/Header/__tests__/Header.test.tsx @@ -16,4 +16,18 @@ describe('Header', () => { within(baseElement).getByRole(scope === 'col' || scope === undefined ? 'columnheader' : 'rowheader'); screen.getByText('label'); }); + + it('Should render Header with class "af-table__th--blank" when isBlank is true', () => { + const { baseElement } = renderWithContainer(
, container); + + const header = within(baseElement).getByRole('columnheader'); + expect(header).toHaveClass('af-table__th af-table__th--blank'); + }); + + it('Should render Header without class "af-table__th--blank" when isBlank is false', () => { + const { baseElement } = renderWithContainer(
, container); + + const header = within(baseElement).getByRole('columnheader'); + expect(header).toHaveClass('af-table__th'); + }); }); diff --git a/src/shared/testsUtils/sharedScenarios/table/utils.ts b/src/shared/testsUtils/sharedScenarios/table/utils.ts index 59e52a6f..58d771f7 100644 --- a/src/shared/testsUtils/sharedScenarios/table/utils.ts +++ b/src/shared/testsUtils/sharedScenarios/table/utils.ts @@ -43,7 +43,10 @@ export const expectTable = async (tableItemsType = DEFAULT_TABLE_ITEMS_TYPE) => }; export const expectCellsContent = (cells: HTMLElement[], ...args: string[]) => { - args + const argsWithoutLast = [...args]; + argsWithoutLast.pop(); + + argsWithoutLast .filter(item => !isNull(item)) .forEach((headerLabel, index) => { expect(cells[index]).toHaveTextContent(RegExp(headerLabel));