mirror of
https://github.com/System-End/github-readme-stats.git
synced 2026-04-19 18:45:21 +00:00
Tests: Add gist endpoint not found test (#3110)
This commit is contained in:
parent
03b0adc8b7
commit
4e69e3a358
1 changed files with 28 additions and 0 deletions
|
|
@ -34,6 +34,14 @@ const gist_data = {
|
|||
},
|
||||
};
|
||||
|
||||
const gist_not_found_data = {
|
||||
data: {
|
||||
viewer: {
|
||||
gist: null,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const mock = new MockAdapter(axios);
|
||||
|
||||
afterEach(() => {
|
||||
|
|
@ -122,4 +130,24 @@ describe("Test /api/gist", () => {
|
|||
),
|
||||
);
|
||||
});
|
||||
|
||||
it("should render error if gist is not found", async () => {
|
||||
const req = {
|
||||
query: {
|
||||
id: "bbfce31e0217a3689c8d961a356cb10d",
|
||||
},
|
||||
};
|
||||
const res = {
|
||||
setHeader: jest.fn(),
|
||||
send: jest.fn(),
|
||||
};
|
||||
mock
|
||||
.onPost("https://api.github.com/graphql")
|
||||
.reply(200, gist_not_found_data);
|
||||
|
||||
await gist(req, res);
|
||||
|
||||
expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
|
||||
expect(res.send).toBeCalledWith(renderError("Gist not found"));
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue