From c5c348e1d505fba5b152595a28eee2176fb609ba Mon Sep 17 00:00:00 2001 From: Alisher Musurmonov Date: Thu, 7 Dec 2023 15:17:41 +0500 Subject: [PATCH] tests: add test case --- .../ViewContact/ViewContactContainer.js | 2 +- .../ViewContact/ViewContactContainer.test.js | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/contacts/ViewContact/ViewContactContainer.js b/src/contacts/ViewContact/ViewContactContainer.js index 8ea7bce9..2c5f00a7 100644 --- a/src/contacts/ViewContact/ViewContactContainer.js +++ b/src/contacts/ViewContact/ViewContactContainer.js @@ -20,12 +20,12 @@ import { DICT_CATEGORIES } from '../../common/constants'; import { getBackPath } from '../../common/utils/createItem'; import { useTranslatedCategories } from '../../common/hooks'; +import { PRIVILEGED_CONTACT_URL_PATH } from '../constants'; import ViewContact from './ViewContact'; import { deleteContact, unassign, } from './util'; -import { PRIVILEGED_CONTACT_URL_PATH } from '../constants'; export function ViewContactContainer({ baseUrl, diff --git a/src/contacts/ViewContact/ViewContactContainer.test.js b/src/contacts/ViewContact/ViewContactContainer.test.js index 618963e0..fca3a860 100644 --- a/src/contacts/ViewContact/ViewContactContainer.test.js +++ b/src/contacts/ViewContact/ViewContactContainer.test.js @@ -2,6 +2,7 @@ import { render, screen } from '@folio/jest-config-stripes/testing-library/react import { match, history } from '../../../test/jest/routerMocks'; import { DICT_CATEGORIES } from '../../common/constants'; +import { PRIVILEGED_CONTACT_URL_PATH } from '../constants'; import ViewContact from './ViewContact'; import { ViewContactContainer } from './ViewContactContainer'; @@ -22,6 +23,12 @@ const defaultProps = { resources: { contact: { isPending: false }, [DICT_CATEGORIES]: { records: [] }, + privilegedContact: { + records: [{ + id: 'contactId', + categories: [], + }], + }, }, match, history: historyMock, @@ -40,6 +47,22 @@ describe('ViewContactContainer', () => { expect(screen.getByText('Icon')).toBeDefined(); }); + it('should display ViewContact with privileged contacts', async () => { + const contactProps = { + ...defaultProps, + match: { + ...defaultProps.match, + path: `/${PRIVILEGED_CONTACT_URL_PATH}`, + }, + }; + + renderViewContactContainer(contactProps); + + await screen.findByText('ViewContact'); + + expect(screen.getByText('ViewContact')).toBeDefined(); + }); + it('should display ViewContact', async () => { renderViewContactContainer();