mirror of
https://github.com/tiennm99/github-readme-stats.git
synced 2026-08-21 08:26:24 +00:00
fix: langs_count overflow when hide is set (#989)
This commit is contained in:
@@ -74,19 +74,6 @@ describe("FetchTopLanguages", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("should fetch langs with specified langs_count", async () => {
|
||||
mock.onPost("https://api.github.com/graphql").reply(200, data_langs);
|
||||
|
||||
let repo = await fetchTopLanguages("anuraghazra", 1);
|
||||
expect(repo).toStrictEqual({
|
||||
javascript: {
|
||||
color: "#0ff",
|
||||
name: "javascript",
|
||||
size: 200,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("should throw error", async () => {
|
||||
mock.onPost("https://api.github.com/graphql").reply(200, error);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
require("@testing-library/jest-dom");
|
||||
const cssToObject = require("css-to-object");
|
||||
const fetchTopLanguages = require("../src/fetchers/top-languages-fetcher");
|
||||
const renderTopLanguages = require("../src/cards/top-languages-card");
|
||||
|
||||
const { queryByTestId, queryAllByTestId } = require("@testing-library/dom");
|
||||
@@ -230,4 +231,22 @@ describe("Test renderTopLanguages", () => {
|
||||
document.body.innerHTML = renderTopLanguages(langs, { });
|
||||
expect(document.querySelector("rect")).toHaveAttribute("rx", "4.5");
|
||||
});
|
||||
|
||||
it("should render langs with specified langs_count", async () => {
|
||||
options = {
|
||||
langs_count: 1
|
||||
}
|
||||
document.body.innerHTML = renderTopLanguages(langs, { ...options });
|
||||
expect(queryAllByTestId(document.body, "lang-name").length).toBe(options.langs_count)
|
||||
});
|
||||
|
||||
it("should render langs with specified langs_count even when hide is set", async () => {
|
||||
options = {
|
||||
hide: ["HTML"],
|
||||
langs_count: 2
|
||||
}
|
||||
document.body.innerHTML = renderTopLanguages(langs, { ...options });
|
||||
expect(queryAllByTestId(document.body, "lang-name").length).toBe(options.langs_count)
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user