mirror of
https://github.com/System-End/github-readme-stats.git
synced 2026-04-19 16:38:23 +00:00
Tests: Add gist endpoint missing id param test (#3106)
This commit is contained in:
parent
93733caaa6
commit
03b0adc8b7
1 changed files with 21 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ import axios from "axios";
|
|||
import MockAdapter from "axios-mock-adapter";
|
||||
import { expect, it, describe, afterEach } from "@jest/globals";
|
||||
import { renderGistCard } from "../src/cards/gist-card.js";
|
||||
import { renderError } from "../src/common/utils.js";
|
||||
import gist from "../api/gist.js";
|
||||
|
||||
const gist_data = {
|
||||
|
|
@ -101,4 +102,24 @@ describe("Test /api/gist", () => {
|
|||
),
|
||||
);
|
||||
});
|
||||
|
||||
it("should render error if id is not provided", async () => {
|
||||
const req = {
|
||||
query: {},
|
||||
};
|
||||
const res = {
|
||||
setHeader: jest.fn(),
|
||||
send: jest.fn(),
|
||||
};
|
||||
|
||||
await gist(req, res);
|
||||
|
||||
expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
|
||||
expect(res.send).toBeCalledWith(
|
||||
renderError(
|
||||
'Missing params "id" make sure you pass the parameters in URL',
|
||||
"/api/gist?id=GIST_ID",
|
||||
),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue