Tests: Add top langs endpoint wrong locale test (#3142)

This commit is contained in:
Alexandr Garbuzov 2023-08-25 10:20:31 +03:00 committed by GitHub
parent 5c688f9e7c
commit 2cf933c81a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -185,4 +185,25 @@ describe("Test /api/top-langs", () => {
expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
expect(res.send).toBeCalledWith(renderError("Something went wrong"));
});
it("should render error card if wrong locale provided", async () => {
const req = {
query: {
username: "anuraghazra",
locale: "asdf",
},
};
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", "Locale not found"),
);
});
});