mirror of
https://github.com/Aviortheking/codestats-readme.git
synced 2025-04-22 10:42:08 +00:00
tests: added more tests for themes (#125)
This commit is contained in:
parent
815916b3f1
commit
92dcc89a3d
@ -149,6 +149,29 @@ describe("Test renderRepoCard", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should render with all the themes", () => {
|
||||||
|
Object.keys(themes).forEach((name) => {
|
||||||
|
document.body.innerHTML = renderRepoCard(data_repo.repository, {
|
||||||
|
theme: name,
|
||||||
|
});
|
||||||
|
|
||||||
|
const styleTag = document.querySelector("style");
|
||||||
|
const stylesObject = cssToObject(styleTag.innerHTML);
|
||||||
|
|
||||||
|
const headerClassStyles = stylesObject[".header"];
|
||||||
|
const descClassStyles = stylesObject[".description"];
|
||||||
|
const iconClassStyles = stylesObject[".icon"];
|
||||||
|
|
||||||
|
expect(headerClassStyles.fill).toBe(`#${themes[name].title_color}`);
|
||||||
|
expect(descClassStyles.fill).toBe(`#${themes[name].text_color}`);
|
||||||
|
expect(iconClassStyles.fill).toBe(`#${themes[name].icon_color}`);
|
||||||
|
expect(queryByTestId(document.body, "card-bg")).toHaveAttribute(
|
||||||
|
"fill",
|
||||||
|
`#${themes[name].bg_color}`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("should render custom colors with themes", () => {
|
it("should render custom colors with themes", () => {
|
||||||
document.body.innerHTML = renderRepoCard(data_repo.repository, {
|
document.body.innerHTML = renderRepoCard(data_repo.repository, {
|
||||||
title_color: "5a0",
|
title_color: "5a0",
|
||||||
|
@ -148,6 +148,29 @@ describe("Test renderStatsCard", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should render with all the themes", () => {
|
||||||
|
Object.keys(themes).forEach((name) => {
|
||||||
|
document.body.innerHTML = renderStatsCard(stats, {
|
||||||
|
theme: name,
|
||||||
|
});
|
||||||
|
|
||||||
|
const styleTag = document.querySelector("style");
|
||||||
|
const stylesObject = cssToObject(styleTag.innerHTML);
|
||||||
|
|
||||||
|
const headerClassStyles = stylesObject[".header"];
|
||||||
|
const statClassStyles = stylesObject[".stat"];
|
||||||
|
const iconClassStyles = stylesObject[".icon"];
|
||||||
|
|
||||||
|
expect(headerClassStyles.fill).toBe(`#${themes[name].title_color}`);
|
||||||
|
expect(statClassStyles.fill).toBe(`#${themes[name].text_color}`);
|
||||||
|
expect(iconClassStyles.fill).toBe(`#${themes[name].icon_color}`);
|
||||||
|
expect(queryByTestId(document.body, "card-bg")).toHaveAttribute(
|
||||||
|
"fill",
|
||||||
|
`#${themes[name].bg_color}`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("should render custom colors with themes and fallback to default colors if invalid", () => {
|
it("should render custom colors with themes and fallback to default colors if invalid", () => {
|
||||||
document.body.innerHTML = renderStatsCard(stats, {
|
document.body.innerHTML = renderStatsCard(stats, {
|
||||||
title_color: "invalid color",
|
title_color: "invalid color",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user