Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit12f84f8

Browse files
authored
tests: add top langs endpoint proper cache header test (anuraghazra#3269)
1 parent1fb2d1a commit12f84f8

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

‎tests/top-langs.test.js‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import axios from "axios";
44
importMockAdapterfrom"axios-mock-adapter";
55
importtopLangsfrom"../api/top-langs.js";
66
import{renderTopLanguages}from"../src/cards/top-languages-card.js";
7-
import{renderError}from"../src/common/utils.js";
7+
import{renderError,CONSTANTS}from"../src/common/utils.js";
88
import{expect,it,describe,afterEach}from"@jest/globals";
99

1010
constdata_langs={
@@ -206,4 +206,27 @@ describe("Test /api/top-langs", () => {
206206
renderError("Something went wrong","Locale not found"),
207207
);
208208
});
209+
210+
it("should have proper cache",async()=>{
211+
constreq={
212+
query:{
213+
username:"anuraghazra",
214+
},
215+
};
216+
constres={
217+
setHeader:jest.fn(),
218+
send:jest.fn(),
219+
};
220+
mock.onPost("https://api.github.com/graphql").reply(200,data_langs);
221+
222+
awaittopLangs(req,res);
223+
224+
expect(res.setHeader).toBeCalledWith("Content-Type","image/svg+xml");
225+
expect(res.setHeader).toBeCalledWith(
226+
"Cache-Control",
227+
`max-age=${CONSTANTS.SIX_HOURS/2}, s-maxage=${
228+
CONSTANTS.SIX_HOURS
229+
}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
230+
);
231+
});
209232
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp