Skip to content

Commit

Permalink
chore: fixing test
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshLarouche committed Aug 25, 2023
1 parent eb2915a commit 43db812
Showing 1 changed file with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const defaultQueryResolver = {
projectName: "Test CIF Project",
rowId: 1,
},
projectAttachmentFormChanges: {
summaryProjectAttachmentFormChanges: {
__id: "test-attachment-form-change-connection-id",
totalCount: 2,
edges: [
Expand Down Expand Up @@ -73,8 +73,20 @@ const defaultQueryResolver = {
},
};

// We're using a wrapper component to avoid rendering errors with <td> elements
// not being in a table.
const TestWrapper: React.FC = (props: any) => {
return (
<table>
<tbody>
<ProjectAttachmentsFormSummary {...props} />
</tbody>
</table>
);
};

const componentTestingHelper = new ComponentTestingHelper<FormIndexPageQuery>({
component: ProjectAttachmentsFormSummary,
component: TestWrapper,
testQuery: testQuery,
compiledQuery: compiledFormIndexPageQuery,
getPropsFromTestQuery: (data) => ({
Expand All @@ -98,4 +110,12 @@ describe("The project's attachment page", () => {
screen.queryByLabelText("upload-attachment")
).not.toBeInTheDocument();
});

it("Displays all attachments", () => {
componentTestingHelper.loadQuery();
componentTestingHelper.renderComponent();

expect(screen.getByText(/test-attachment-1.jpg/i)).toBeInTheDocument();
expect(screen.getByText(/test-attachment-2.jpg/i)).toBeInTheDocument();
});
});

0 comments on commit 43db812

Please sign in to comment.