Skip to content

Commit 8089362

Browse files
test: add more tests for ReferencesAndCitationsCardContent
1 parent 28d82d6 commit 8089362

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/integration/paper-components/paper-view/cards/references-and-citations-card-content.test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,38 @@ describe("ReferencesAndCitationsCardContent", () => {
7474
const paper2 = screen.queryByText(Papers.demoPaper2.title, { exact: false });
7575
expect(paper2).not.toBeInTheDocument();
7676
});
77+
78+
test("When references and citations are empty, then hint is shown", async () => {
79+
render(ReferencesAndCitationsCardContent, {
80+
target: document.body,
81+
props: {
82+
backwardReferencedPapers: Promise.resolve([]),
83+
forwardReferencedPapers: Promise.resolve([]),
84+
},
85+
});
86+
87+
await waitForComponentLoading();
88+
89+
const referencesHint = screen.getByText("No references found.");
90+
expect(referencesHint).toBeInTheDocument();
91+
const citationsHint = screen.getByText("No citations found.");
92+
expect(citationsHint).toBeInTheDocument();
93+
});
94+
95+
test("When loading references and citations failed, then an error hint is shown", async () => {
96+
render(ReferencesAndCitationsCardContent, {
97+
target: document.body,
98+
props: {
99+
backwardReferencedPapers: Promise.reject("error"),
100+
forwardReferencedPapers: Promise.reject("error"),
101+
},
102+
});
103+
104+
await waitForComponentLoading();
105+
106+
const referencesHint = screen.getByText("Couldn't load references.");
107+
expect(referencesHint).toBeInTheDocument();
108+
const citationsHint = screen.getByText("Couldn't load citations.");
109+
expect(citationsHint).toBeInTheDocument();
110+
});
77111
});

0 commit comments

Comments
 (0)