From b35f34f52a999827424846642415cf36e99f248f Mon Sep 17 00:00:00 2001 From: Jasper Swart Date: Wed, 15 Jan 2020 09:14:12 +0100 Subject: [PATCH] added test for fetching services --- .../IncidentSplitContainer/index.test.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/signals/incident-management/containers/IncidentSplitContainer/index.test.js b/src/signals/incident-management/containers/IncidentSplitContainer/index.test.js index 5c2959ac7c..4ddbbb698a 100644 --- a/src/signals/incident-management/containers/IncidentSplitContainer/index.test.js +++ b/src/signals/incident-management/containers/IncidentSplitContainer/index.test.js @@ -2,6 +2,7 @@ import React from 'react'; import { render, } from '@testing-library/react'; +import * as reactRouterDom from 'react-router-dom'; import { withAppContext } from 'test/utils'; import incident from 'utils/__tests__/fixtures/incident.json'; @@ -12,12 +13,16 @@ import { IncidentSplitContainer, mapDispatchToProps } from './index'; import stadsdeelList from '../../definitions/stadsdeelList'; import priorityList from '../../definitions/priorityList'; +jest.mock('react-router-dom', () => ({ + __esModule: true, + ...jest.requireActual('react-router-dom'), +})); + describe('', () => { let props; beforeEach(() => { props = { - id: '42', categories: { sub: [], }, @@ -33,6 +38,10 @@ describe('', () => { onSplitIncident: jest.fn(), onGoBack: jest.fn(), }; + + jest.spyOn(reactRouterDom, 'useParams').mockImplementation(() => ({ + id: '42', + })); }); describe('rendering', () => { @@ -44,6 +53,9 @@ describe('', () => { expect(queryByTestId('splitDetailTitle')).toHaveTextContent(/^Melding 6666$/); expect(queryAllByTestId('incidentPartTitle')[0]).toHaveTextContent(/^Deelmelding 1$/); expect(queryAllByTestId('incidentPartTitle')[1]).toHaveTextContent(/^Deelmelding 2$/); + + expect(props.onRequestIncident).toHaveBeenCalledWith('42'); + expect(props.onRequestAttachments).toHaveBeenCalledWith('42'); }); });