From fa4d7ee7a163af9698f89175b83ed5916533c87d Mon Sep 17 00:00:00 2001 From: Alexandr Garbuzov Date: Tue, 6 Jun 2023 09:56:23 +0300 Subject: [PATCH] Cover with test changes in #2770 pull request (#2775) --- tests/top-langs.test.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/top-langs.test.js b/tests/top-langs.test.js index b5232c29..7d0747f8 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"), + ); + }); });