mirror of
https://github.com/tiennm99/github-readme-stats.git
synced 2026-05-14 06:58:59 +00:00
Tests: Add gist endpoint not found test (#3110)
This commit is contained in:
committed by
GitHub
parent
03b0adc8b7
commit
4e69e3a358
@@ -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"));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user