Skip to content

Commit

Permalink
fix tests and types
Browse files Browse the repository at this point in the history
  • Loading branch information
stephmilovic committed Mar 9, 2020
1 parent 48d49ff commit 4616822
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const useGetCasesMockState: UseGetCasesState = {
id: '3c4ddcc0-4e99-11ea-9290-35d05cb55c15',
createdAt: '2020-02-13T19:44:23.627Z',
createdBy: { username: 'elastic' },
commentIds: [],
comments: [],
description: 'Security banana Issue',
state: 'open',
Expand All @@ -26,6 +27,7 @@ export const useGetCasesMockState: UseGetCasesState = {
id: '362a5c10-4e99-11ea-9290-35d05cb55c15',
createdAt: '2020-02-13T19:44:13.328Z',
createdBy: { username: 'elastic' },
commentIds: [],
comments: [],
description: 'Security banana Issue',
state: 'open',
Expand All @@ -38,6 +40,7 @@ export const useGetCasesMockState: UseGetCasesState = {
id: '34f8b9e0-4e99-11ea-9290-35d05cb55c15',
createdAt: '2020-02-13T19:44:11.328Z',
createdBy: { username: 'elastic' },
commentIds: [],
comments: [],
description: 'Security banana Issue',
state: 'open',
Expand All @@ -50,6 +53,7 @@ export const useGetCasesMockState: UseGetCasesState = {
id: '31890e90-4e99-11ea-9290-35d05cb55c15',
createdAt: '2020-02-13T19:44:05.563Z',
createdBy: { username: 'elastic' },
commentIds: [],
comments: [],
description: 'Security banana Issue',
state: 'closed',
Expand All @@ -62,6 +66,7 @@ export const useGetCasesMockState: UseGetCasesState = {
id: '2f5b3210-4e99-11ea-9290-35d05cb55c15',
createdAt: '2020-02-13T19:44:01.901Z',
createdBy: { username: 'elastic' },
commentIds: [],
comments: [],
description: 'Security banana Issue',
state: 'open',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,36 @@ import { AllCases } from './';
import { TestProviders } from '../../../../mock';
import { useGetCasesMockState } from './__mock__';
import * as apiHook from '../../../../containers/case/use_get_cases';
import { act } from '@testing-library/react';
import { wait } from '../../../../lib/helpers';

describe('AllCases', () => {
const dispatchUpdateCaseProperty = jest.fn();
const getCaseCount = jest.fn();
const refetchCases = jest.fn();
const setFilters = jest.fn();
const setQueryParams = jest.fn();
const setSelectedCases = jest.fn();
const getCaseCount = jest.fn();
const dispatchUpdateCaseProperty = jest.fn();
beforeEach(() => {
jest.resetAllMocks();
jest.spyOn(apiHook, 'useGetCases').mockReturnValue({
...useGetCasesMockState,
dispatchUpdateCaseProperty,
getCaseCount,
refetchCases,
setFilters,
setQueryParams,
setSelectedCases,
});
moment.tz.setDefault('UTC');
});
it('should render AllCases', () => {
it('should render AllCases', async () => {
const wrapper = mount(
<TestProviders>
<AllCases />
</TestProviders>
);
await act(() => wait());
expect(
wrapper
.find(`a[data-test-subj="case-details-link"]`)
Expand Down Expand Up @@ -73,12 +78,13 @@ describe('AllCases', () => {
.text()
).toEqual('Showing 10 cases');
});
it('should tableHeaderSortButton AllCases', () => {
it('should tableHeaderSortButton AllCases', async () => {
const wrapper = mount(
<TestProviders>
<AllCases />
</TestProviders>
);
await act(() => wait());
wrapper
.find('[data-test-subj="tableHeaderSortButton"]')
.first()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,13 @@
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';
import { EuiContextMenuItem } from '@elastic/eui';
import React, { useMemo } from 'react';
import * as i18n from './translations';
import { Case } from '../../../../containers/case/types';

interface GetBulkItems {
// cases: Case[];
closePopover: () => void;
deleteCasesAction: (cases: string[]) => void;
// dispatch: Dispatch<Action>;
// dispatchToaster: Dispatch<ActionToaster>;
// reFetchCases: (refreshPrePackagedCase?: boolean) => void;
selectedCaseIds: string[];
caseStatus: string;
}
Expand All @@ -24,9 +19,6 @@ export const getBulkItems = ({
deleteCasesAction,
closePopover,
caseStatus,
// dispatch,
// dispatchToaster,
// reFetchCases,
selectedCaseIds,
}: GetBulkItems) => {
return [
Expand All @@ -48,9 +40,6 @@ export const getBulkItems = ({
disabled={true} // TO DO
onClick={() => {
closePopover();

// deleteCasesAction(selectedCaseIds);
// reFetchCases(true);
}}
>
{i18n.BULK_ACTION_OPEN_SELECTED}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const caseProps: CaseProps = {
caseId: '3c4ddcc0-4e99-11ea-9290-35d05cb55c15',
initialData: {
id: '3c4ddcc0-4e99-11ea-9290-35d05cb55c15',
commentIds: ['a357c6a0-5435-11ea-b427-fb51a1fcb7b8'],
comments: [
{
comment: 'Solve this fast!',
Expand All @@ -37,6 +38,7 @@ export const caseProps: CaseProps = {

export const data: Case = {
id: '3c4ddcc0-4e99-11ea-9290-35d05cb55c15',
commentIds: ['a357c6a0-5435-11ea-b427-fb51a1fcb7b8'],
comments: [
{
comment: 'Solve this fast!',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export const CaseComponent = React.memo<CaseProps>(({ caseId, initialData }) =>
<ConfirmDeleteCaseModal
caseTitle={caseData.title}
isModalVisible={isDisplayConfirmDeleteModal}
isPlural={false}
onCancel={handleToggleModal}
onConfirm={handleOnDeleteConfirm.bind(null, [caseId])}
/>
Expand Down

0 comments on commit 4616822

Please sign in to comment.