Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UIIN-1766 create JEST/RTL for InstanceNotesList.js #2091

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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(
<Router>
<InstanceNotesList {...props} />
</Router>
)
);

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();
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand how this test is related to the noValue component. Rather, it validates that the note's type is used as a column header, which is the same thing tested on line 33. From a coverage point of view, you're running the noValue code here, but not asserting on it. Effectively that throws away the value of the test.

});