From 011c2c680a1c28431f6653eb24232395ba695502 Mon Sep 17 00:00:00 2001 From: ssandupatla <58558770+ssandupatla@users.noreply.github.com> Date: Wed, 29 Mar 2023 11:19:27 +0530 Subject: [PATCH 1/2] UIIN-1766 create JEST/RTL for InstanceNotesList.js --- .../InstanceNotesList.test.js | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/Instance/InstanceDetails/InstanceNotesView/InstanceNotesList.test.js diff --git a/src/Instance/InstanceDetails/InstanceNotesView/InstanceNotesList.test.js b/src/Instance/InstanceDetails/InstanceNotesView/InstanceNotesList.test.js new file mode 100644 index 000000000..265783253 --- /dev/null +++ b/src/Instance/InstanceDetails/InstanceNotesView/InstanceNotesList.test.js @@ -0,0 +1,42 @@ +import React from 'react'; +import { BrowserRouter as Router } from 'react-router-dom'; + +import '../../../../test/jest/__mock__'; +import renderWithIntl from '../../../../test/jest/helpers/renderWithIntl'; + +import InstanceNotesList from './InstanceNotesList'; + +const props1 = { + id: 'InstanceNotesListID', + notesType: 'test-notes', + notes: [{ staffOnly: true, note: 'Note 1' }], +}; + +const noValueProps = { + id: 'test-id', + notesType: 'test-notes', + notes: [], +}; + +const renderInstanceNotesList = (props) => ( + renderWithIntl( + + + + ) +); + +describe('InstanceNotesList', () => { + it('Should renders correctly', () => { + const { getByText } = renderInstanceNotesList(props1); + expect(getByText('ui-inventory.staffOnly')).toBeInTheDocument(); + expect(getByText('test-notes')).toBeInTheDocument(); + expect(getByText('ui-inventory.yes')).toBeInTheDocument(); + expect(getByText('Note 1')).toBeInTheDocument(); + expect(getByText('stripes-components.endOfList')).toBeInTheDocument(); + }); + it('should render the noValue component when notes is empty', () => { + const { getByText } = renderInstanceNotesList(noValueProps); + expect(getByText('test-notes')).toBeInTheDocument(); + }); +}); From f8b2988ad3badd620b9e7e1854f715acf37c6a53 Mon Sep 17 00:00:00 2001 From: ssandupatla <58558770+ssandupatla@users.noreply.github.com> Date: Fri, 5 May 2023 17:56:10 +0530 Subject: [PATCH 2/2] UIIN-1766 updated JEST/RTL test case for InstanceNotesList.js --- .../InstanceNotesView/InstanceNotesList.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Instance/InstanceDetails/InstanceNotesView/InstanceNotesList.test.js b/src/Instance/InstanceDetails/InstanceNotesView/InstanceNotesList.test.js index 265783253..0be20260c 100644 --- a/src/Instance/InstanceDetails/InstanceNotesView/InstanceNotesList.test.js +++ b/src/Instance/InstanceDetails/InstanceNotesView/InstanceNotesList.test.js @@ -36,7 +36,7 @@ describe('InstanceNotesList', () => { expect(getByText('stripes-components.endOfList')).toBeInTheDocument(); }); it('should render the noValue component when notes is empty', () => { - const { getByText } = renderInstanceNotesList(noValueProps); - expect(getByText('test-notes')).toBeInTheDocument(); + const { getAllByText } = renderInstanceNotesList(noValueProps); + expect(getAllByText('stripes-components.noValue.noValueSet')).toBeDefined(); }); });