Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions src/components/record/RecordRow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ const RecordRow = (props) => {
{`${record.author.firstName} ${record.author.lastName}`}
</Button>
) : (
<span className="text-warning">Not Found</span>
"—"
)}
</td>
)}

{props.visibleColumns.includes(COLUMNS.INSTITUTION) && (
<td className="report-row content-center">{record.institution.name}</td>
<td className="report-row content-center">{record.institution ? record.institution.name : "—"}</td>
)}

{props.visibleColumns.includes(COLUMNS.TEMPLATE) && (
Expand Down
9 changes: 7 additions & 2 deletions tests/__tests__/components/RecordRow.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,21 @@ describe("RecordRow", function () {
expect(screen.queryByText("Thomas Shelby")).not.toBeInTheDocument();
});

it("renders 'Not Found' for author if firstName or lastName are missing", () => {
it("renders '' for author if firstName or lastName are missing", () => {
renderComponent({ record: { ...defaultProps.record, author: { username: "Thomas" } } });
expect(screen.getByText("Not Found")).toBeInTheDocument();
expect(screen.getByText("")).toBeInTheDocument();
});

it("renders institution if it is visible", () => {
renderComponent();
expect(screen.getByText(defaultProps.record.institution.name)).toBeInTheDocument();
});

it("renders '—' for institution if it is missing", () => {
renderComponent({ record: { ...defaultProps.record, institution: null } });
expect(screen.getByText("—")).toBeInTheDocument();
});

it("does not render institution if it is not visible", () => {
renderComponent({ visibleColumns: Object.values(COLUMNS).filter((col) => col !== COLUMNS.INSTITUTION) });
expect(screen.queryByText(defaultProps.record.institution.name)).not.toBeInTheDocument();
Expand Down