From f1de7a191be680cfa751c2d07bfcfd80966e8714 Mon Sep 17 00:00:00 2001 From: Alexandr Date: Thu, 24 Aug 2023 04:42:23 +0300 Subject: [PATCH] Tests: Add top langs endpoint blacklist test --- tests/top-langs.test.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/top-langs.test.js b/tests/top-langs.test.js index 3f4e594aa7295..f1c7d0082f38a 100644 --- a/tests/top-langs.test.js +++ b/tests/top-langs.test.js @@ -167,4 +167,22 @@ describe("Test /api/top-langs", () => { renderError("Something went wrong", "Incorrect layout input"), ); }); + + it("should render error card if username in blacklist", async () => { + const req = { + query: { + username: "renovate-bot", + }, + }; + 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")); + }); });