Skip to content

Commit

Permalink
tests: add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
alisher-epam committed Dec 7, 2023
1 parent 56027c1 commit b8a8272
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/contacts/EditContact/EditContactContainer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { DICT_CATEGORIES } from '../../common/constants';
import { saveContact } from './util';
import EditContact from './EditContact';
import { EditContactContainer } from './EditContactContainer';
import { PRIVILEGED_CONTACT_URL_PATH } from '../constants';

jest.mock('./util', () => ({
saveContact: jest.fn(),
Expand Down Expand Up @@ -81,4 +82,37 @@ describe('EditContactContainer', () => {

expect(saveContact).toHaveBeenCalled();
});

describe('Privileged contact actions', () => {
const props = {
...defaultProps,
match: {
...defaultProps.match,
path: `/contacts/view/:id/${PRIVILEGED_CONTACT_URL_PATH}`,
},
onClose: undefined,
};

it('should save privileged contacts', async () => {
saveContact.mockClear().mockReturnValue(Promise.resolve());

renderEditContactContainer(props);

await screen.findByText('EditContact');

EditContact.mock.calls[0][0].onSubmit({});

expect(saveContact).toHaveBeenCalled();
});

it('should redirect to org details when form is closed', async () => {
renderEditContactContainer(props);

await screen.findByText('EditContact');

EditContact.mock.calls[0][0].onClose();

expect(historyMock.push).toHaveBeenCalledWith('/organizations/orgId/privileged-contacts/id/view');
});
});
});

0 comments on commit b8a8272

Please sign in to comment.