From 037e32a51d34b24148357d04cd01874383f94210 Mon Sep 17 00:00:00 2001 From: Tyler Ohlsen Date: Mon, 10 Aug 2020 17:47:02 -0700 Subject: [PATCH] Add UT for Detector List page --- .../components/EmptyMessage/EmptyMessage.tsx | 4 +- .../__tests__/EmptyMessage.test.tsx | 24 +- .../__snapshots__/EmptyMessage.test.tsx.snap | 4 +- .../__tests__/ListActions.test.tsx | 27 +- .../ConfirmDeleteDetectorsModal.test.tsx | 28 +- .../containers/List/__tests__/List.test.tsx | 254 +++++++++++++++++- .../utils/__tests__/helpers.test.ts | 134 ++++++++- .../utils/__tests__/tableUtils.test.tsx | 52 ++++ 8 files changed, 498 insertions(+), 29 deletions(-) create mode 100644 public/pages/DetectorsList/utils/__tests__/tableUtils.test.tsx diff --git a/public/pages/DetectorsList/components/EmptyMessage/EmptyMessage.tsx b/public/pages/DetectorsList/components/EmptyMessage/EmptyMessage.tsx index 2a8d06a9..1438440f 100644 --- a/public/pages/DetectorsList/components/EmptyMessage/EmptyMessage.tsx +++ b/public/pages/DetectorsList/components/EmptyMessage/EmptyMessage.tsx @@ -40,7 +40,7 @@ export const EmptyDetectorMessage = (props: EmptyDetectorProps) => ( Reset filters @@ -48,7 +48,7 @@ export const EmptyDetectorMessage = (props: EmptyDetectorProps) => ( Create detector diff --git a/public/pages/DetectorsList/components/EmptyMessage/__tests__/EmptyMessage.test.tsx b/public/pages/DetectorsList/components/EmptyMessage/__tests__/EmptyMessage.test.tsx index 1bf642b3..52e58e91 100644 --- a/public/pages/DetectorsList/components/EmptyMessage/__tests__/EmptyMessage.test.tsx +++ b/public/pages/DetectorsList/components/EmptyMessage/__tests__/EmptyMessage.test.tsx @@ -20,23 +20,15 @@ import { EmptyDetectorMessage } from '../EmptyMessage'; describe(' spec', () => { describe('Empty results', () => { test('renders component with empty message', () => { - const { container } = render( + const { container, getByText } = render( ); expect(container.firstChild).toMatchSnapshot(); + getByText('Create detector'); }); - // test.only('should navigate to create detector page', () => { - // const { getByTestId, debug } = render( - // - // - // - // ); - // fireEvent.click(getByTestId('add_detector')); - // expect(location).toBe('/create-detector'); - // }); }); describe('Filters results message', () => { test('renders component no result for filters message', () => { @@ -48,17 +40,17 @@ describe(' spec', () => { ); expect(container.firstChild).toMatchSnapshot(); }); - test('resets filters when click on rest filters', () => { - const handleRestFilters = jest.fn(); + test('resets filters when click on reset filters', () => { + const handleResetFilters = jest.fn(); const { getByTestId } = render( ); - fireEvent.click(getByTestId('reset_list_filters')); - expect(handleRestFilters).toHaveBeenCalled(); - expect(handleRestFilters).toHaveBeenCalledTimes(1); + fireEvent.click(getByTestId('resetListFilters')); + expect(handleResetFilters).toHaveBeenCalled(); + expect(handleResetFilters).toHaveBeenCalledTimes(1); }); }); }); diff --git a/public/pages/DetectorsList/components/EmptyMessage/__tests__/__snapshots__/EmptyMessage.test.tsx.snap b/public/pages/DetectorsList/components/EmptyMessage/__tests__/__snapshots__/EmptyMessage.test.tsx.snap index 6d0140e5..9a2f9809 100644 --- a/public/pages/DetectorsList/components/EmptyMessage/__tests__/__snapshots__/EmptyMessage.test.tsx.snap +++ b/public/pages/DetectorsList/components/EmptyMessage/__tests__/__snapshots__/EmptyMessage.test.tsx.snap @@ -28,7 +28,7 @@ exports[` spec Empty results renders component with empt /> @@ -73,7 +73,7 @@ exports[` spec Filters results message renders component />