Cover with test changes in #2770 pull request (#2775)

This commit is contained in:
Alexandr Garbuzov 2023-06-06 09:56:23 +03:00 committed by GitHub
parent 14fe4cf1db
commit fa4d7ee7a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 = { const req = {
query: { query: {
username: "anuraghazra", username: "anuraghazra",
@ -140,4 +140,25 @@ describe("Test /api/top-langs", () => {
expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml"); expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
expect(res.send).toBeCalledWith(renderError(error.errors[0].message)); 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"),
);
});
}); });