Tests: Add pin endpoint missing params test (#3151)

This commit is contained in:
Alexandr Garbuzov 2023-08-27 10:55:31 +03:00 committed by GitHub
parent 1c91d1ac43
commit b6156a8688
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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",
),
);
});
});