From 66b5031db1c28c852b832e0137bba3d6f74186ca Mon Sep 17 00:00:00 2001 From: Alexandr Garbuzov Date: Sun, 27 Aug 2023 10:55:31 +0300 Subject: [PATCH] Tests: Add pin endpoint missing params test (#3151) --- tests/pin.test.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/pin.test.js b/tests/pin.test.js index cff0bbd41af4a1..dec6a24718a773 100644 --- a/tests/pin.test.js +++ b/tests/pin.test.js @@ -179,4 +179,24 @@ describe("Test /api/pin", () => { renderError("Something went wrong", "Language not found"), ); }); + + it("should render error card if missing required parameters", async () => { + const req = { + query: {}, + }; + const res = { + setHeader: jest.fn(), + send: jest.fn(), + }; + + await pin(req, res); + + expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml"); + expect(res.send).toBeCalledWith( + renderError( + 'Missing params "username", "repo" make sure you pass the parameters in URL', + "/api/pin?username=USERNAME&repo=REPO_NAME", + ), + ); + }); });