Skip to content

Commit

Permalink
Merge pull request #578 from Amsterdam/hot-fix-splitsen-issue-test
Browse files Browse the repository at this point in the history
added test for fetching services
  • Loading branch information
jasperswart authored Jan 15, 2020
2 parents 8f3a520 + b35f34f commit 1ae4d56
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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('<IncidentSplitContainer />', () => {
let props;

beforeEach(() => {
props = {
id: '42',
categories: {
sub: [],
},
Expand All @@ -33,6 +38,10 @@ describe('<IncidentSplitContainer />', () => {
onSplitIncident: jest.fn(),
onGoBack: jest.fn(),
};

jest.spyOn(reactRouterDom, 'useParams').mockImplementation(() => ({
id: '42',
}));
});

describe('rendering', () => {
Expand All @@ -44,6 +53,9 @@ describe('<IncidentSplitContainer />', () => {
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');
});
});

Expand Down

0 comments on commit 1ae4d56

Please sign in to comment.