fix: langs_count overflow when hide is set (#989)

This commit is contained in:
Florian Bussmann
2021-05-07 00:31:04 +05:30
committed by GitHub
parent 7a096acf66
commit f8b0c8767e
5 changed files with 27 additions and 21 deletions
+19
View File
@@ -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)
});
});