mirror of
https://github.com/System-End/github-readme-stats.git
synced 2026-04-19 19:55:16 +00:00
Tests: Stats card: Add hide all stats and rank icon test (#3149)
This commit is contained in:
parent
b6156a8688
commit
cb037aefd8
1 changed files with 15 additions and 0 deletions
|
|
@ -6,6 +6,7 @@ import {
|
||||||
import { cssToObject } from "@uppercod/css-to-object";
|
import { cssToObject } from "@uppercod/css-to-object";
|
||||||
import { renderStatsCard } from "../src/cards/stats-card.js";
|
import { renderStatsCard } from "../src/cards/stats-card.js";
|
||||||
import { expect, it, describe } from "@jest/globals";
|
import { expect, it, describe } from "@jest/globals";
|
||||||
|
import { CustomError } from "../src/common/utils.js";
|
||||||
|
|
||||||
// adds special assertions like toHaveTextContent
|
// adds special assertions like toHaveTextContent
|
||||||
import "@testing-library/jest-dom";
|
import "@testing-library/jest-dom";
|
||||||
|
|
@ -449,4 +450,18 @@ describe("Test renderStatsCard", () => {
|
||||||
queryByTestId(document.body, "percentile-rank-value").textContent.trim(),
|
queryByTestId(document.body, "percentile-rank-value").textContent.trim(),
|
||||||
).toBe(stats.rank.percentile.toFixed(1) + "%");
|
).toBe(stats.rank.percentile.toFixed(1) + "%");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should throw error if all stats and rank icon are hidden", () => {
|
||||||
|
expect(() =>
|
||||||
|
renderStatsCard(stats, {
|
||||||
|
hide: ["stars", "commits", "prs", "issues", "contribs"],
|
||||||
|
hide_rank: true,
|
||||||
|
}),
|
||||||
|
).toThrow(
|
||||||
|
new CustomError(
|
||||||
|
"Could not render stats card.",
|
||||||
|
"Either stats or rank are required.",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue