Skip to content

Commit ba43a2d

Browse files
hesreallyhimReally Him
andauthored
Fix tests (#10)
* test: fixing tests * test: fix test --------- Co-authored-by: Really Him <hesereallyhim@proton.me>
1 parent 6a8d627 commit ba43a2d

3 files changed

Lines changed: 20 additions & 16 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cards/types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export type RepoCardOptions = CommonOptions & {
3737
description_lines_count: number;
3838
hide_title: boolean;
3939
hide_text: boolean;
40+
all_stats?: boolean;
4041
stats_only?: boolean;
4142
show_issues?: boolean;
4243
show_prs?: boolean;

tests/pin.test.js

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { CACHE_TTL, DURATIONS } from "../src/common/cache.js";
1111

1212
const data_repo = {
1313
repository: {
14-
username: "anuraghazra",
14+
nameWithOwner: "anuraghazra",
1515
name: "convoychat",
1616
stargazers: {
1717
totalCount: 38000,
@@ -24,6 +24,9 @@ const data_repo = {
2424
},
2525
forkCount: 100,
2626
isTemplate: false,
27+
isPrivate: false,
28+
isArchived: false,
29+
firstCommitDate: "2018-10-01T00:00:00Z",
2730
},
2831
};
2932

@@ -75,8 +78,8 @@ describe("Test /api/pin", () => {
7578
text_color: "fff",
7679
bg_color: "fff",
7780
full_name: "1",
78-
hide_title: "true",
79-
hide_text: "true",
81+
hide_title: true,
82+
hide_text: true,
8083
},
8184
};
8285
const res = {
@@ -118,7 +121,7 @@ describe("Test /api/pin", () => {
118121

119122
await pin(req, res);
120123

121-
expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
124+
expect(res.setHeader).toHaveBeenCalledWith("Content-Type", "image/svg+xml");
122125
const expectedSvg = renderRepoCard(
123126
{
124127
...data_repo.repository,
@@ -137,15 +140,15 @@ describe("Test /api/pin", () => {
137140
border_radius: undefined,
138141
border_color: undefined,
139142
show_owner: undefined,
140-
locale: null,
143+
locale: undefined,
141144
description_lines_count: undefined,
142145
show_issues: undefined,
143146
show_prs: undefined,
144147
show_age: undefined,
145148
age_metric: "first",
146149
},
147150
);
148-
expect(res.send).toBeCalledWith(expectedSvg);
151+
expect(res.send).toHaveBeenCalledWith(expectedSvg);
149152
});
150153

151154
it("should make all_stats enable issues, PRs, and age", async () => {
@@ -167,7 +170,7 @@ describe("Test /api/pin", () => {
167170

168171
await pin(req, res);
169172

170-
expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
173+
expect(res.setHeader).toHaveBeenCalledWith("Content-Type", "image/svg+xml");
171174
const expectedSvg = renderRepoCard(
172175
{
173176
...data_repo.repository,
@@ -177,7 +180,6 @@ describe("Test /api/pin", () => {
177180
hide_border: undefined,
178181
hide_title: undefined,
179182
hide_text: undefined,
180-
stats_only: false,
181183
title_color: undefined,
182184
icon_color: undefined,
183185
text_color: undefined,
@@ -186,15 +188,16 @@ describe("Test /api/pin", () => {
186188
border_radius: undefined,
187189
border_color: undefined,
188190
show_owner: undefined,
189-
locale: null,
191+
locale: undefined,
190192
description_lines_count: undefined,
191-
show_issues: true,
192-
show_prs: true,
193-
show_age: true,
193+
show_issues: false,
194+
show_prs: false,
195+
show_age: false,
196+
all_stats: true,
194197
age_metric: "first",
195198
},
196199
);
197-
expect(res.send).toBeCalledWith(expectedSvg);
200+
expect(res.send).toHaveBeenCalledWith(expectedSvg);
198201
});
199202

200203
it("should render error card if repo not found", async () => {
@@ -214,7 +217,7 @@ describe("Test /api/pin", () => {
214217

215218
await pin(req, res);
216219

217-
expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
220+
expect(res.setHeader).toHaveBeenCalledWith("Content-Type", "image/svg+xml");
218221
expect(res.send).toHaveBeenCalledWith(
219222
renderError({ message: "Repository Not found" }),
220223
);

0 commit comments

Comments
 (0)