Tests: Add gist endpoint not found test (#3110)

This commit is contained in:
Alexandr Garbuzov 2023-08-21 10:07:47 +03:00 committed by GitHub
parent 03b0adc8b7
commit 4e69e3a358
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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