feat: display username in repo card (optional) (#78)

* Display username in repo card (optional)

* fix: show_owner boolean flag & used nameWithOwner from gql api
This commit is contained in:
omrilotan
2020-07-16 15:33:33 +03:00
committed by GitHub
parent 597dac2985
commit 9e4d83247e
6 changed files with 37 additions and 8 deletions

View File

@@ -6,6 +6,7 @@ const { queryByTestId } = require("@testing-library/dom");
const data_repo = {
repository: {
nameWithOwner: "anuraghazra/convoychat",
name: "convoychat",
stargazers: { totalCount: 38000 },
description: "Help us take over the world! React + TS + GraphQL Chat App",
@@ -22,9 +23,10 @@ describe("Test renderRepoCard", () => {
it("should render correctly", () => {
document.body.innerHTML = renderRepoCard(data_repo.repository);
expect(document.getElementsByClassName("header")[0]).toHaveTextContent(
"convoychat"
);
const [header] = document.getElementsByClassName("header");
expect(header).toHaveTextContent("convoychat");
expect(header).not.toHaveTextContent("anuraghazra");
expect(document.getElementsByClassName("description")[0]).toHaveTextContent(
"Help us take over the world! React + TS + GraphQL Chat .."
);
@@ -39,6 +41,15 @@ describe("Test renderRepoCard", () => {
);
});
it("should display username in title (full repo name)", () => {
document.body.innerHTML = renderRepoCard(data_repo.repository, {
show_owner: true,
});
expect(document.getElementsByClassName("header")[0]).toHaveTextContent(
"anuraghazra/convoychat"
);
});
it("should trim description", () => {
document.body.innerHTML = renderRepoCard({
...data_repo.repository,