feat: added repo card hide border option (#488)

* 🚀 Prettier config

* 🚀 hide_border for Repo Card

* fix: wrong total commits (#490)

* chore: run prettier on all files

* chore: lol lets add the trailing commas

Co-authored-by: Anurag Hazra <hazru.anurag@gmail.com>
This commit is contained in:
Bas950andAnurag Hazra authored and GitHub committed 2020-09-24 21:38:14 +05:30
1 parent 3c6c142c75
commit 8aea1e3c35
35 files changed
+152 -134

No files matched your search

+7 -7
View File
@@ -97,8 +97,8 @@ describe("Test /api/", () => {
expect(res.send).toBeCalledWith(
renderError(
error.errors[0].message,
"Make sure the provided username is not an organization"
)
"Make sure the provided username is not an organization",
),
);
});
@@ -115,7 +115,7 @@ describe("Test /api/", () => {
text_color: "fff",
bg_color: "fff",
},
data
data,
);
await api(req, res);
@@ -131,7 +131,7 @@ describe("Test /api/", () => {
icon_color: "fff",
text_color: "fff",
bg_color: "fff",
})
}),
);
});
@@ -196,7 +196,7 @@ describe("Test /api/", () => {
username: "anuraghazra",
count_private: true,
},
data
data,
);
await api(req, res);
@@ -217,8 +217,8 @@ describe("Test /api/", () => {
issues: stats.totalIssues,
}),
},
{}
)
{},
),
);
});
});
+1 -1
View File
@@ -12,7 +12,7 @@ describe("Test calculateRank", () => {
stargazers: 400,
prs: 300,
issues: 200,
})
}),
).toStrictEqual({ level: "A+", score: 49.16605417270399 });
});
});
+13 -13
View File
@@ -13,7 +13,7 @@ describe("Card", () => {
document.body.innerHTML = card.render(``);
expect(queryByTestId(document.body, "card-bg")).toHaveAttribute(
"stroke-opacity",
"0"
"0",
);
});
@@ -24,7 +24,7 @@ describe("Card", () => {
document.body.innerHTML = card.render(``);
expect(queryByTestId(document.body, "card-bg")).toHaveAttribute(
"stroke-opacity",
"1"
"1",
);
});
@@ -63,11 +63,11 @@ describe("Card", () => {
document.body.innerHTML = card.render(``);
expect(document.getElementsByTagName("svg")[0]).toHaveAttribute(
"height",
"200"
"200",
);
expect(document.getElementsByTagName("svg")[0]).toHaveAttribute(
"height",
"200"
"200",
);
});
@@ -78,7 +78,7 @@ describe("Card", () => {
document.body.innerHTML = card.render(``);
expect(document.getElementsByTagName("svg")[0]).toHaveAttribute(
"height",
"170"
"170",
);
});
@@ -87,7 +87,7 @@ describe("Card", () => {
document.body.innerHTML = card.render(``);
expect(queryByTestId(document.body, "main-card-body")).toHaveAttribute(
"transform",
"translate(0, 55)"
"translate(0, 55)",
);
});
@@ -98,7 +98,7 @@ describe("Card", () => {
document.body.innerHTML = card.render(``);
expect(queryByTestId(document.body, "main-card-body")).toHaveAttribute(
"transform",
"translate(0, 25)"
"translate(0, 25)",
);
});
@@ -130,7 +130,7 @@ describe("Card", () => {
expect(headerClassStyles.fill).toBe("#f00");
expect(queryByTestId(document.body, "card-bg")).toHaveAttribute(
"fill",
"#fff"
"#fff",
);
});
it("should render gradient backgrounds", () => {
@@ -154,20 +154,20 @@ describe("Card", () => {
document.body.innerHTML = card.render(``);
expect(queryByTestId(document.body, "card-bg")).toHaveAttribute(
"fill",
"url(#gradient)"
"url(#gradient)",
);
expect(document.querySelector("defs linearGradient")).toHaveAttribute(
"gradientTransform",
"rotate(90)"
"rotate(90)",
);
expect(
document.querySelector("defs linearGradient stop:nth-child(1)")
document.querySelector("defs linearGradient stop:nth-child(1)"),
).toHaveAttribute("stop-color", "#fff");
expect(
document.querySelector("defs linearGradient stop:nth-child(2)")
document.querySelector("defs linearGradient stop:nth-child(2)"),
).toHaveAttribute("stop-color", "#000");
expect(
document.querySelector("defs linearGradient stop:nth-child(3)")
document.querySelector("defs linearGradient stop:nth-child(3)"),
).toHaveAttribute("stop-color", "#f00");
});
});
+4 -4
View File
@@ -57,7 +57,7 @@ describe("Test fetchRepo", () => {
.reply(200, { data: { user: { repository: null }, organization: null } });
await expect(fetchRepo("anuraghazra", "convoychat")).rejects.toThrow(
"User Repository Not found"
"User Repository Not found",
);
});
@@ -67,7 +67,7 @@ describe("Test fetchRepo", () => {
.reply(200, { data: { user: null, organization: { repository: null } } });
await expect(fetchRepo("anuraghazra", "convoychat")).rejects.toThrow(
"Organization Repository Not found"
"Organization Repository Not found",
);
});
@@ -77,7 +77,7 @@ describe("Test fetchRepo", () => {
.reply(200, { data: { user: null, organization: null } });
await expect(fetchRepo("anuraghazra", "convoychat")).rejects.toThrow(
"Not found"
"Not found",
);
});
@@ -90,7 +90,7 @@ describe("Test fetchRepo", () => {
});
await expect(fetchRepo("anuraghazra", "convoychat")).rejects.toThrow(
"User Repository Not found"
"User Repository Not found",
);
});
});
+1 -1
View File
@@ -77,7 +77,7 @@ describe("Test fetchStats", () => {
mock.onPost("https://api.github.com/graphql").reply(200, error);
await expect(fetchStats("anuraghazra")).rejects.toThrow(
"Could not resolve to a User with the login of 'noname'."
"Could not resolve to a User with the login of 'noname'.",
);
});
+1 -1
View File
@@ -91,7 +91,7 @@ describe("FetchTopLanguages", () => {
mock.onPost("https://api.github.com/graphql").reply(200, error);
await expect(fetchTopLanguages("anuraghazra")).rejects.toThrow(
"Could not resolve to a User with the login of 'noname'."
"Could not resolve to a User with the login of 'noname'.",
);
});
});
+2 -2
View File
@@ -105,7 +105,7 @@ describe("Wakatime fetcher", () => {
const username = "anuraghazra";
mock
.onGet(
`https://wakatime.com/api/v1/users/${username}/stats/last_7_days?is_including_today=true`
`https://wakatime.com/api/v1/users/${username}/stats/last_7_days?is_including_today=true`,
)
.reply(200, wakaTimeData);
@@ -207,7 +207,7 @@ describe("Wakatime fetcher", () => {
mock.onGet(/\/https:\/\/wakatime\.com\/api/).reply(404, wakaTimeData);
await expect(fetchLast7Days("noone")).rejects.toThrow(
"Request failed with status code 404"
"Request failed with status code 404",
);
});
});
+2 -2
View File
@@ -76,7 +76,7 @@ describe("Test /api/pin", () => {
expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
expect(res.send).toBeCalledWith(
renderRepoCard(data_repo.repository, { ...req.query })
renderRepoCard(data_repo.repository, { ...req.query }),
);
});
@@ -120,7 +120,7 @@ describe("Test /api/pin", () => {
expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
expect(res.send).toBeCalledWith(
renderError("Organization Repository Not found")
renderError("Organization Repository Not found"),
);
});
});
+17 -17
View File
@@ -29,16 +29,16 @@ describe("Test renderRepoCard", () => {
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 App"
"Help us take over the world! React + TS + GraphQL Chat App",
);
expect(queryByTestId(document.body, "stargazers")).toHaveTextContent("38k");
expect(queryByTestId(document.body, "forkcount")).toHaveTextContent("100");
expect(queryByTestId(document.body, "lang-name")).toHaveTextContent(
"TypeScript"
"TypeScript",
);
expect(queryByTestId(document.body, "lang-color")).toHaveAttribute(
"fill",
"#2b7489"
"#2b7489",
);
});
@@ -47,7 +47,7 @@ describe("Test renderRepoCard", () => {
show_owner: true,
});
expect(document.getElementsByClassName("header")[0]).toHaveTextContent(
"anuraghazra/convoychat"
"anuraghazra/convoychat",
);
});
@@ -59,11 +59,11 @@ describe("Test renderRepoCard", () => {
});
expect(
document.getElementsByClassName("description")[0].children[0].textContent
document.getElementsByClassName("description")[0].children[0].textContent,
).toBe("The quick brown fox jumps over the lazy dog is an");
expect(
document.getElementsByClassName("description")[0].children[1].textContent
document.getElementsByClassName("description")[0].children[1].textContent,
).toBe("English-language pangram—a sentence that contains all");
// Should not trim
@@ -73,7 +73,7 @@ describe("Test renderRepoCard", () => {
});
expect(document.getElementsByClassName("description")[0]).toHaveTextContent(
"Small text should not trim"
"Small text should not trim",
);
});
@@ -85,7 +85,7 @@ describe("Test renderRepoCard", () => {
// poop emoji may not show in all editors but it's there between "a" and "poo"
expect(document.getElementsByClassName("description")[0]).toHaveTextContent(
"This is a text with a 💩 poo emoji"
"This is a text with a 💩 poo emoji",
);
});
@@ -101,7 +101,7 @@ describe("Test renderRepoCard", () => {
expect(queryByTestId(document.body, "primary-lang")).toBeInTheDocument();
expect(queryByTestId(document.body, "star-fork-group")).toHaveAttribute(
"transform",
"translate(155, 0)"
"translate(155, 0)",
);
// Small lang
@@ -115,7 +115,7 @@ describe("Test renderRepoCard", () => {
expect(queryByTestId(document.body, "star-fork-group")).toHaveAttribute(
"transform",
"translate(125, 0)"
"translate(125, 0)",
);
});
@@ -135,11 +135,11 @@ describe("Test renderRepoCard", () => {
expect(queryByTestId(document.body, "primary-lang")).toBeInTheDocument();
expect(queryByTestId(document.body, "lang-color")).toHaveAttribute(
"fill",
"#333"
"#333",
);
expect(queryByTestId(document.body, "lang-name")).toHaveTextContent(
"Unspecified"
"Unspecified",
);
});
@@ -158,7 +158,7 @@ describe("Test renderRepoCard", () => {
expect(iconClassStyles.fill).toBe("#586069");
expect(queryByTestId(document.body, "card-bg")).toHaveAttribute(
"fill",
"#fffefe"
"#fffefe",
);
});
@@ -186,7 +186,7 @@ describe("Test renderRepoCard", () => {
expect(iconClassStyles.fill).toBe(`#${customColors.icon_color}`);
expect(queryByTestId(document.body, "card-bg")).toHaveAttribute(
"fill",
"#252525"
"#252525",
);
});
@@ -208,7 +208,7 @@ describe("Test renderRepoCard", () => {
expect(iconClassStyles.fill).toBe(`#${themes[name].icon_color}`);
expect(queryByTestId(document.body, "card-bg")).toHaveAttribute(
"fill",
`#${themes[name].bg_color}`
`#${themes[name].bg_color}`,
);
});
});
@@ -231,7 +231,7 @@ describe("Test renderRepoCard", () => {
expect(iconClassStyles.fill).toBe(`#${themes.radical.icon_color}`);
expect(queryByTestId(document.body, "card-bg")).toHaveAttribute(
"fill",
`#${themes.radical.bg_color}`
`#${themes.radical.bg_color}`,
);
});
@@ -254,7 +254,7 @@ describe("Test renderRepoCard", () => {
expect(iconClassStyles.fill).toBe(`#${themes.radical.icon_color}`);
expect(queryByTestId(document.body, "card-bg")).toHaveAttribute(
"fill",
`#${themes.radical.bg_color}`
`#${themes.radical.bg_color}`,
);
});
+12 -12
View File
@@ -24,11 +24,11 @@ describe("Test renderStatsCard", () => {
document.body.innerHTML = renderStatsCard(stats);
expect(document.getElementsByClassName("header")[0].textContent).toBe(
"Anurag Hazra's GitHub Stats"
"Anurag Hazra's GitHub Stats",
);
expect(
document.body.getElementsByTagName("svg")[0].getAttribute("height")
document.body.getElementsByTagName("svg")[0].getAttribute("height"),
).toBe("195");
expect(getByTestId(document.body, "stars").textContent).toBe("100");
expect(getByTestId(document.body, "commits").textContent).toBe("200");
@@ -43,13 +43,13 @@ describe("Test renderStatsCard", () => {
document.body.innerHTML = renderStatsCard({ ...stats, name: "Anil Das" });
expect(document.getElementsByClassName("header")[0].textContent).toBe(
"Anil Das' GitHub Stats"
"Anil Das' GitHub Stats",
);
document.body.innerHTML = renderStatsCard({ ...stats, name: "Felix" });
expect(document.getElementsByClassName("header")[0].textContent).toBe(
"Felix' GitHub Stats"
"Felix' GitHub Stats",
);
});
@@ -59,7 +59,7 @@ describe("Test renderStatsCard", () => {
});
expect(
document.body.getElementsByTagName("svg")[0].getAttribute("height")
document.body.getElementsByTagName("svg")[0].getAttribute("height"),
).toBe("150"); // height should be 150 because we clamped it.
expect(queryByTestId(document.body, "stars")).toBeDefined();
@@ -90,7 +90,7 @@ describe("Test renderStatsCard", () => {
expect(iconClassStyles.fill).toBe("#4c71f2");
expect(queryByTestId(document.body, "card-bg")).toHaveAttribute(
"fill",
"#fffefe"
"#fffefe",
);
});
@@ -116,7 +116,7 @@ describe("Test renderStatsCard", () => {
expect(iconClassStyles.fill).toBe(`#${customColors.icon_color}`);
expect(queryByTestId(document.body, "card-bg")).toHaveAttribute(
"fill",
"#252525"
"#252525",
);
});
@@ -138,7 +138,7 @@ describe("Test renderStatsCard", () => {
expect(iconClassStyles.fill).toBe(`#${themes.radical.icon_color}`);
expect(queryByTestId(document.body, "card-bg")).toHaveAttribute(
"fill",
`#${themes.radical.bg_color}`
`#${themes.radical.bg_color}`,
);
});
@@ -160,7 +160,7 @@ describe("Test renderStatsCard", () => {
expect(iconClassStyles.fill).toBe(`#${themes[name].icon_color}`);
expect(queryByTestId(document.body, "card-bg")).toHaveAttribute(
"fill",
`#${themes[name].bg_color}`
`#${themes[name].bg_color}`,
);
});
});
@@ -184,7 +184,7 @@ describe("Test renderStatsCard", () => {
expect(iconClassStyles.fill).toBe(`#${themes.radical.icon_color}`);
expect(queryByTestId(document.body, "card-bg")).toHaveAttribute(
"fill",
`#${themes.radical.bg_color}`
`#${themes.radical.bg_color}`,
);
});
@@ -196,7 +196,7 @@ describe("Test renderStatsCard", () => {
expect(queryAllByTestId(document.body, "icon")[0]).toBeDefined();
expect(queryByTestId(document.body, "stars")).toBeDefined();
expect(
queryByTestId(document.body, "stars").previousElementSibling // the label
queryByTestId(document.body, "stars").previousElementSibling, // the label
).toHaveAttribute("x", "25");
});
@@ -206,7 +206,7 @@ describe("Test renderStatsCard", () => {
expect(queryAllByTestId(document.body, "icon")[0]).not.toBeDefined();
expect(queryByTestId(document.body, "stars")).toBeDefined();
expect(
queryByTestId(document.body, "stars").previousElementSibling // the label
queryByTestId(document.body, "stars").previousElementSibling, // the label
).not.toHaveAttribute("x");
});
});
+22 -22
View File
@@ -28,29 +28,29 @@ describe("Test renderTopLanguages", () => {
document.body.innerHTML = renderTopLanguages(langs);
expect(queryByTestId(document.body, "header")).toHaveTextContent(
"Most Used Languages"
"Most Used Languages",
);
expect(queryAllByTestId(document.body, "lang-name")[0]).toHaveTextContent(
"HTML"
"HTML",
);
expect(queryAllByTestId(document.body, "lang-name")[1]).toHaveTextContent(
"javascript"
"javascript",
);
expect(queryAllByTestId(document.body, "lang-name")[2]).toHaveTextContent(
"css"
"css",
);
expect(queryAllByTestId(document.body, "lang-progress")[0]).toHaveAttribute(
"width",
"40%"
"40%",
);
expect(queryAllByTestId(document.body, "lang-progress")[1]).toHaveAttribute(
"width",
"40%"
"40%",
);
expect(queryAllByTestId(document.body, "lang-progress")[2]).toHaveAttribute(
"width",
"20%"
"20%",
);
});
@@ -59,10 +59,10 @@ describe("Test renderTopLanguages", () => {
hide: ["HTML"],
});
expect(queryAllByTestId(document.body, "lang-name")[0]).toBeInTheDocument(
"javascript"
"javascript",
);
expect(queryAllByTestId(document.body, "lang-name")[1]).toBeInTheDocument(
"css"
"css",
);
expect(queryAllByTestId(document.body, "lang-name")[2]).not.toBeDefined();
@@ -71,7 +71,7 @@ describe("Test renderTopLanguages", () => {
hide: ["HTML", "css"],
});
expect(queryAllByTestId(document.body, "lang-name")[0]).toBeInTheDocument(
"javascript"
"javascript",
);
expect(queryAllByTestId(document.body, "lang-name")[1]).not.toBeDefined();
});
@@ -89,7 +89,7 @@ describe("Test renderTopLanguages", () => {
size: 100,
},
},
{}
{},
);
expect(document.querySelector("svg")).toHaveAttribute("height", "245");
});
@@ -116,7 +116,7 @@ describe("Test renderTopLanguages", () => {
expect(langNameStyles.fill).toBe("#333");
expect(queryByTestId(document.body, "card-bg")).toHaveAttribute(
"fill",
"#fffefe"
"#fffefe",
);
});
@@ -140,7 +140,7 @@ describe("Test renderTopLanguages", () => {
expect(langNameStyles.fill).toBe(`#${customColors.text_color}`);
expect(queryByTestId(document.body, "card-bg")).toHaveAttribute(
"fill",
"#252525"
"#252525",
);
});
@@ -160,7 +160,7 @@ describe("Test renderTopLanguages", () => {
expect(langNameStyles.fill).toBe(`#${themes.radical.text_color}`);
expect(queryByTestId(document.body, "card-bg")).toHaveAttribute(
"fill",
`#${themes.radical.bg_color}`
`#${themes.radical.bg_color}`,
);
});
@@ -180,7 +180,7 @@ describe("Test renderTopLanguages", () => {
expect(langNameStyles.fill).toBe(`#${themes[name].text_color}`);
expect(queryByTestId(document.body, "card-bg")).toHaveAttribute(
"fill",
`#${themes[name].bg_color}`
`#${themes[name].bg_color}`,
);
});
});
@@ -189,31 +189,31 @@ describe("Test renderTopLanguages", () => {
document.body.innerHTML = renderTopLanguages(langs, { layout: "compact" });
expect(queryByTestId(document.body, "header")).toHaveTextContent(
"Most Used Languages"
"Most Used Languages",
);
expect(queryAllByTestId(document.body, "lang-name")[0]).toHaveTextContent(
"HTML 40.00%"
"HTML 40.00%",
);
expect(queryAllByTestId(document.body, "lang-progress")[0]).toHaveAttribute(
"width",
"120.00"
"120.00",
);
expect(queryAllByTestId(document.body, "lang-name")[1]).toHaveTextContent(
"javascript 40.00%"
"javascript 40.00%",
);
expect(queryAllByTestId(document.body, "lang-progress")[1]).toHaveAttribute(
"width",
"120.00"
"120.00",
);
expect(queryAllByTestId(document.body, "lang-name")[2]).toHaveTextContent(
"css 20.00%"
"css 20.00%",
);
expect(queryAllByTestId(document.body, "lang-progress")[2]).toHaveAttribute(
"width",
"60.00"
"60.00",
);
});
});
+1 -1
View File
@@ -9,7 +9,7 @@ const fetcher = jest.fn((variables, token) => {
const fetcherFail = jest.fn(() => {
return new Promise((res, rej) =>
res({ data: { errors: [{ type: "RATE_LIMITED" }] } })
res({ data: { errors: [{ type: "RATE_LIMITED" }] } }),
);
});
+1 -1
View File
@@ -118,7 +118,7 @@ describe("Test /api/top-langs", () => {
icon_color: "fff",
text_color: "fff",
bg_color: "fff",
})
}),
);
});
+8 -8
View File
@@ -23,24 +23,24 @@ describe("Test utils.js", () => {
it("should test encodeHTML", () => {
expect(encodeHTML(`<html>hello world<,.#4^&^@%!))`)).toBe(
"&#60;html&#62;hello world&#60;,.#4^&#38;^@%!))"
"&#60;html&#62;hello world&#60;,.#4^&#38;^@%!))",
);
});
it("should test renderError", () => {
document.body.innerHTML = renderError("Something went wrong");
expect(
queryByTestId(document.body, "message").children[0]
queryByTestId(document.body, "message").children[0],
).toHaveTextContent(/Something went wrong/gim);
expect(queryByTestId(document.body, "message").children[1]).toBeEmpty(2);
// Secondary message
document.body.innerHTML = renderError(
"Something went wrong",
"Secondary Message"
"Secondary Message",
);
expect(
queryByTestId(document.body, "message").children[1]
queryByTestId(document.body, "message").children[1],
).toHaveTextContent(/Secondary Message/gim);
});
@@ -51,7 +51,7 @@ describe("Test utils.js", () => {
}).join("");
expect(layout).toBe(
`<g transform=\"translate(0, 0)\"><text>1</text></g><g transform=\"translate(60, 0)\"><text>2</text></g>`
`<g transform=\"translate(0, 0)\"><text>1</text></g><g transform=\"translate(60, 0)\"><text>2</text></g>`,
);
const columns = FlexLayout({
@@ -61,7 +61,7 @@ describe("Test utils.js", () => {
}).join("");
expect(columns).toBe(
`<g transform=\"translate(0, 0)\"><text>1</text></g><g transform=\"translate(0, 60)\"><text>2</text></g>`
`<g transform=\"translate(0, 0)\"><text>1</text></g><g transform=\"translate(0, 60)\"><text>2</text></g>`,
);
});
@@ -121,7 +121,7 @@ describe("wrapTextMultiline", () => {
let multiLineText = wrapTextMultiline(
"Hello world long long long text",
20,
3
3,
);
expect(multiLineText).toEqual(["Hello world long", "long long text"]);
});
@@ -129,7 +129,7 @@ describe("wrapTextMultiline", () => {
let multiLineText = wrapTextMultiline(
"Hello world long long long text",
10,
2
2,
);
expect(multiLineText).toEqual(["Hello", "world long..."]);
});