Skip to content

Commit

Permalink
Tests: Add pin endpoint missing params test (anuraghazra#3151)
Browse files Browse the repository at this point in the history
  • Loading branch information
qwerty541 authored and devantler committed Sep 24, 2023
1 parent 4c892f4 commit 81f49df
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/pin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
),
);
});
});

0 comments on commit 81f49df

Please sign in to comment.