8000 chore: update · hypernova7/github-readme-stats@53e4041 · GitHub
[go: up one dir, main page]

Skip to content

Commit 53e4041

Browse files
committed
chore: update
1 parent cdc6ad1 commit 53e4041

File tree

5 files changed

+3
-156
lines changed

5 files changed

+3
-156
lines changed

api/top-langs.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { renderTopLanguages } from "../src/cards/top-languages-card.js";
22
import { blacklist } from "../src/common/blacklist.js";
33
import {
4-
clampValue,
54
CONSTANTS,
65
parseArray,
76
parseBoolean,

tests/api.test.js

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -168,40 +168,6 @@ describe("Test /api/", () => {
168168
);
169169
});
170170

171-
it("should have proper cache", async () => {
172-
const { req, res } = faker({}, data_stats);
173-
174-
await api(req, res);
175-
176-
expect(res.setHeader.mock.calls).toEqual([
177-
["Content-Type", "image/svg+xml"],
178-
[
179-
"Cache-Control",
180-
`max-age=${CONSTANTS.SIX_HOURS / 2}, s-maxage=${
181-
CONSTANTS.SIX_HOURS
182-
}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
183-
],
184-
]);
185-
});
186-
187-
it("should set proper cache", async () => {
188-
const cache_seconds = 35000;
189-
const { req, res } = faker({ cache_seconds }, data_stats);
190-
await api(req, res);
191-
192-
expect(res.setHeader.mock.calls).toEqual([
193-
["Content-Type", "image/svg+xml"],
194-
[
195-
"Cache-Control",
196-
`max-age=${
197-
cache_seconds / 2
198-
}, s-maxage=${cache_seconds}, stale-while-revalidate=${
199-
CONSTANTS.ONE_DAY
200-
}`,
201-
],
202-
]);
203-
});
204-
205171
it("should set shorter cache when error", async () => {
206172
const { req, res } = faker({}, error);
207173
await api(req, res);
@@ -217,54 +183,6 @@ describe("Test /api/", () => {
217183
]);
218184
});
219185

220-
it("should set proper cache with clamped values", async () => {
221-
{
222-
let { req, res } = faker({ cache_seconds: 200000 }, data_stats);
223-
await api(req, res);
224-
225-
expect(res.setHeader.mock.calls).toEqual([
226-
["Content-Type", "image/svg+xml"],
227-
[
228-
"Cache-Control",
229-
`max-age=${CONSTANTS.ONE_DAY / 2}, s-maxage=${
230-
CONSTANTS.ONE_DAY
231-
}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
232-
],
233-
]);
234-
}
235-
236-
// note i'm using block scoped vars
237-
{
238-
let { req, res } = faker({ cache_seconds: 0 }, data_stats);
239-
await api(req, res);
240-
241-
expect(res.setHeader.mock.calls).toEqual([
242-
["Content-Type", "image/svg+xml"],
243-
[
244-
"Cache-Control",
245-
`max-age=${CONSTANTS.SIX_HOURS / 2}, s-maxage=${
246-
CONSTANTS.SIX_HOURS
247-
}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
248-
],
249-
]);
250-
}
251-
252-
{
253-
let { req, res } = faker({ cache_seconds: -10000 }, data_stats);
254-
await api(req, res);
255-
256-
expect(res.setHeader.mock.calls).toEqual([
257-
["Content-Type", "image/svg+xml"],
258-
[
259-
"Cache-Control",
260-
`max-age=${CONSTANTS.SIX_HOURS / 2}, s-maxage=${
261-
CONSTANTS.SIX_HOURS
262-
}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
263-
],
264-
]);
265-
}
266-
});
267-
268186
it("should allow changing ring_color", async () => {
269187
const { req, res } = faker(
270188
{

tests/gist.test.js

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import axios from "axios";
44
import MockAdapter from "axios-mock-adapter";
55
import { expect, it, describe, afterEach } from "@jest/globals";
66
import { renderGistCard } from "../src/cards/gist-card.js";
7-
import { renderError, CONSTANTS } from "../src/common/utils.js";
7+
import { renderError } from "../src/common/utils.js";
88
import gist from "../api/gist.js";
99

1010
const gist_data = {
@@ -170,27 +170,4 @@ describe("Test /api/gist", () => {
170170
renderError("Something went wrong", "Language not found"),
171171
);
172172
});
173-
174-
it("should have proper cache", async () => {
175-
const req = {
176-
query: {
177-
id: "bbfce31e0217a3689c8d961a356cb10d",
178-
},
179-
};
180-
const res = {
181-
setHeader: jest.fn(),
182-
send: jest.fn(),
183-
};
184-
mock.onPost("https://api.github.com/graphql").reply(200, gist_data);
185-
186-
await gist(req, res);
187-
188-
expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
189-
expect(res.setHeader).toBeCalledWith(
190-
"Cache-Control",
191-
`max-age=${CONSTANTS.SIX_HOURS / 2}, s-maxage=${
192-
CONSTANTS.SIX_HOURS
193-
}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
194-
);
195-
});
196173
});

tests/pin.test.js

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import axios from "axios";
44
import MockAdapter from "axios-mock-adapter";
55
import pin from "../api/pin.js";
66
import { renderRepoCard } from "../src/cards/repo-card.js";
7-
import { renderError, CONSTANTS } from "../src/common/utils.js";
7+
import { renderError } from "../src/common/utils.js";
88
import { expect, it, describe, afterEach } from "@jest/globals";
99

1010
const data_repo = {
@@ -201,28 +201,4 @@ describe("Test /api/pin", () => {
201201
),
202202
);
203203
});
204-
205-
it("should have proper cache", async () => {
206-
const req = {
207-
query: {
208-
username: "anuraghazra",
209-
repo: "convoychat",
210-
},
211-
};
212-
const res = {
213-
setHeader: jest.fn(),
214-
send: jest.fn(),
215-
};
216-
mock.onPost("https://api.github.com/graphql").reply(200, data_user);
217-
218-
await pin(req, res);
219-
220-
expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
221-
expect(res.setHeader).toBeCalledWith(
222-
"Cache-Control",
223-
`max-age=${CONSTANTS.SIX_HOURS / 2}, s-maxage=${
224-
CONSTANTS.SIX_HOURS
225-
}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
226-
);
227-
});
228204
});

tests/top-langs.test.js

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

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

0 commit comments

Comments
 (0)
0