From 4cf33ad1bf4c0b0cefd60c1a02bf34a4fbdbfb71 Mon Sep 17 00:00:00 2001 From: Alexandr Garbuzov Date: Tue, 22 Aug 2023 10:03:59 +0300 Subject: [PATCH] Tests: Add gist endpoint wrong locale test (#3127) --- tests/gist.test.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/gist.test.js b/tests/gist.test.js index b7c3484..bdf9515 100644 --- a/tests/gist.test.js +++ b/tests/gist.test.js @@ -150,4 +150,24 @@ describe("Test /api/gist", () => { expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml"); expect(res.send).toBeCalledWith(renderError("Gist not found")); }); + + it("should render error if wrong locale is provided", async () => { + const req = { + query: { + id: "bbfce31e0217a3689c8d961a356cb10d", + locale: "asdf", + }, + }; + const res = { + setHeader: jest.fn(), + send: jest.fn(), + }; + + await gist(req, res); + + expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml"); + expect(res.send).toBeCalledWith( + renderError("Something went wrong", "Language not found"), + ); + }); });