Files
snk/packages/github-user-contribution/__tests__/getGithubUserContribution.spec.ts
2022-11-03 08:45:33 +01:00

36 lines
1.0 KiB
TypeScript

import { getGithubUserContribution } from "..";
describe("getGithubUserContribution", () => {
const promise = getGithubUserContribution("platane");
it("should resolve", async () => {
await promise;
});
it("should get around 365 cells", async () => {
const cells = await promise;
expect(cells.length).toBeGreaterThanOrEqual(365);
expect(cells.length).toBeLessThanOrEqual(365 + 7);
});
it("cells should have x / y coords representing to a 7 x (365/7) (minus unfilled last row)", async () => {
const cells = await promise;
expect(cells.length).toBeGreaterThan(300);
const undefinedDays = Array.from({ length: Math.floor(365 / 7) })
.map((x) => Array.from({ length: 7 }).map((y) => ({ x, y })))
.flat()
.filter(({ x, y }) => cells.some((c: any) => c.x === x && c.y === y));
expect(undefinedDays).toEqual([]);
});
});
xit("should match snapshot for year=2019", async () => {
expect(
await getGithubUserContribution("platane", { year: 2019 })
).toMatchSnapshot();
});