Skip to content

Commit

Permalink
Cover with test changes in anuraghazra#2770 pull request (anuraghazra…
Browse files Browse the repository at this point in the history
  • Loading branch information
qwerty541 authored and devantler committed Sep 24, 2023
1 parent 538b6cd commit bb237d8
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion tests/top-langs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ describe("Test /api/top-langs", () => {
);
});

it("should render error card on error", async () => {
it("should render error card on user data fetch error", async () => {
const req = {
query: {
username: "anuraghazra",
Expand All @@ -140,4 +140,25 @@ describe("Test /api/top-langs", () => {
expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
expect(res.send).toBeCalledWith(renderError(error.errors[0].message));
});

it("should render error card on incorrect layout input", async () => {
const req = {
query: {
username: "anuraghazra",
layout: ["pie"],
},
};
const res = {
setHeader: jest.fn(),
send: jest.fn(),
};
mock.onPost("https://api.github.com/graphql").reply(200, data_langs);

await topLangs(req, res);

expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
expect(res.send).toBeCalledWith(
renderError("Something went wrong", "Incorrect layout input"),
);
});
});

0 comments on commit bb237d8

Please sign in to comment.