Skip to content
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();
});
Comment on lines +38 to +41
Copy link
Copy Markdown
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.

});