mirror of
https://github.com/System-End/github-readme-stats.git
synced 2026-04-19 21:05:16 +00:00
tests: add pin endpoint proper cache header test (#3260)
This commit is contained in:
parent
2ee803fc16
commit
41a2ba8cbe
1 changed files with 25 additions and 1 deletions
|
|
@ -4,7 +4,7 @@ import axios from "axios";
|
|||
import MockAdapter from "axios-mock-adapter";
|
||||
import pin from "../api/pin.js";
|
||||
import { renderRepoCard } from "../src/cards/repo-card.js";
|
||||
import { renderError } from "../src/common/utils.js";
|
||||
import { renderError, CONSTANTS } from "../src/common/utils.js";
|
||||
import { expect, it, describe, afterEach } from "@jest/globals";
|
||||
|
||||
const data_repo = {
|
||||
|
|
@ -199,4 +199,28 @@ describe("Test /api/pin", () => {
|
|||
),
|
||||
);
|
||||
});
|
||||
|
||||
it("should have proper cache", async () => {
|
||||
const req = {
|
||||
query: {
|
||||
username: "anuraghazra",
|
||||
repo: "convoychat",
|
||||
},
|
||||
};
|
||||
const res = {
|
||||
setHeader: jest.fn(),
|
||||
send: jest.fn(),
|
||||
};
|
||||
mock.onPost("https://api.github.com/graphql").reply(200, data_user);
|
||||
|
||||
await pin(req, res);
|
||||
|
||||
expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
|
||||
expect(res.setHeader).toBeCalledWith(
|
||||
"Cache-Control",
|
||||
`max-age=${CONSTANTS.SIX_HOURS / 2}, s-maxage=${
|
||||
CONSTANTS.SIX_HOURS
|
||||
}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue