Skip to content

Commit 66b5031

Browse files
committed
Tests: Add pin endpoint missing params test (anuraghazra#3151)
1 parent 2c7220f commit 66b5031

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/pin.test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,24 @@ describe("Test /api/pin", () => {
179179
renderError("Something went wrong", "Language not found"),
180180
);
181181
});
182+
183+
it("should render error card if missing required parameters", async () => {
184+
const req = {
185+
query: {},
186+
};
187+
const res = {
188+
setHeader: jest.fn(),
189+
send: jest.fn(),
190+
};
191+
192+
await pin(req, res);
193+
194+
expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
195+
expect(res.send).toBeCalledWith(
196+
renderError(
197+
'Missing params "username", "repo" make sure you pass the parameters in URL',
198+
"/api/pin?username=USERNAME&repo=REPO_NAME",
199+
),
200+
);
201+
});
182202
});

0 commit comments

Comments
 (0)