mirror of
https://github.com/anuraghazra/github-readme-stats.git
synced 2024-12-27 06:25:47 +08:00
parent
14fe4cf1db
commit
fa4d7ee7a1
@ -123,7 +123,7 @@ describe("Test /api/top-langs", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should render error card on error", async () => {
|
it("should render error card on user data fetch error", async () => {
|
||||||
const req = {
|
const req = {
|
||||||
query: {
|
query: {
|
||||||
username: "anuraghazra",
|
username: "anuraghazra",
|
||||||
@ -140,4 +140,25 @@ describe("Test /api/top-langs", () => {
|
|||||||
expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
|
expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
|
||||||
expect(res.send).toBeCalledWith(renderError(error.errors[0].message));
|
expect(res.send).toBeCalledWith(renderError(error.errors[0].message));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should render error card on incorrect layout input", async () => {
|
||||||
|
const req = {
|
||||||
|
query: {
|
||||||
|
username: "anuraghazra",
|
||||||
|
layout: ["pie"],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const res = {
|
||||||
|
setHeader: jest.fn(),
|
||||||
|
send: jest.fn(),
|
||||||
|
};
|
||||||
|
mock.onPost("https://api.github.com/graphql").reply(200, data_langs);
|
||||||
|
|
||||||
|
await topLangs(req, res);
|
||||||
|
|
||||||
|
expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
|
||||||
|
expect(res.send).toBeCalledWith(
|
||||||
|
renderError("Something went wrong", "Incorrect layout input"),
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user