diff --git a/tests/top-langs.test.js b/tests/top-langs.test.js index b5232c29af3d5..7d0747f812cc1 100644 --- a/tests/top-langs.test.js +++ b/tests/top-langs.test.js @@ -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", @@ -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"), + ); + }); });