From df9b83f8b7418cd3fd4dfb8df69db8f3015cd25e Mon Sep 17 00:00:00 2001 From: Christos Nasikas Date: Tue, 8 Dec 2020 16:57:36 +0200 Subject: [PATCH] Improve tests --- .../all_cases_modal.test.tsx | 28 +++++++++++++++++-- .../use_all_cases_modal/index.test.tsx | 1 - 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/security_solution/public/cases/components/use_all_cases_modal/all_cases_modal.test.tsx b/x-pack/plugins/security_solution/public/cases/components/use_all_cases_modal/all_cases_modal.test.tsx index c8e0da3c2659696..e4fb1b12676f64a 100644 --- a/x-pack/plugins/security_solution/public/cases/components/use_all_cases_modal/all_cases_modal.test.tsx +++ b/x-pack/plugins/security_solution/public/cases/components/use_all_cases_modal/all_cases_modal.test.tsx @@ -3,6 +3,8 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ + +/* eslint-disable react/display-name */ import { mount } from 'enzyme'; import React from 'react'; import '../../../common/mock/match_media'; @@ -10,10 +12,19 @@ import { AllCasesModal } from './all_cases_modal'; import { TestProviders } from '../../../common/mock'; jest.mock('../all_cases', () => { - const AllCases = () => { - return <>; + return { + AllCases: ({ onRowClick }: { onRowClick: (id: string, title: string) => void }) => { + return ( + + ); + }, }; - return { AllCases }; }); jest.mock('../../../common/lib/kibana', () => { @@ -82,4 +93,15 @@ describe('AllCasesModal', () => { isModal: true, }); }); + + it('onRowClick called when row is clicked', () => { + const wrapper = mount( + + + + ); + + wrapper.find(`[data-test-subj='all-cases-row']`).first().simulate('click'); + expect(onRowClick).toHaveBeenCalledWith('case-id', 'case title'); + }); }); diff --git a/x-pack/plugins/security_solution/public/cases/components/use_all_cases_modal/index.test.tsx b/x-pack/plugins/security_solution/public/cases/components/use_all_cases_modal/index.test.tsx index dcf5097489ee951..aad30391ffc5258 100644 --- a/x-pack/plugins/security_solution/public/cases/components/use_all_cases_modal/index.test.tsx +++ b/x-pack/plugins/security_solution/public/cases/components/use_all_cases_modal/index.test.tsx @@ -5,7 +5,6 @@ */ /* eslint-disable react/display-name */ - import React from 'react'; import { renderHook, act } from '@testing-library/react-hooks'; import { render, screen } from '@testing-library/react';