Skip to content

Commit d9a14e8

Browse files
committed
Fix tests
1 parent ac62022 commit d9a14e8

4 files changed

Lines changed: 15 additions & 2 deletions

File tree

src/utils.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,13 @@ export function buildUrl(
8484
path: string,
8585
parameters: qs.ParsedUrlQueryInput,
8686
): string {
87-
return `${_internals.getBaseUrl()}${path}?${qs.stringify(parameters)}`;
87+
const clonedParams = { ...parameters };
88+
for (const k in clonedParams) {
89+
if (clonedParams[k] === undefined) {
90+
delete clonedParams[k];
91+
}
92+
}
93+
return `${_internals.getBaseUrl()}${path}?${qs.stringify(clonedParams)}`;
8894
}
8995

9096
export function execute(

tests/engines/google_test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ describe("google", {
9898
api_key: "test_override_api_key",
9999
q: "coffee",
100100
});
101+
} catch {
102+
// pass
101103
} finally {
102104
executeSpy.restore();
103105
}
@@ -177,6 +179,8 @@ describe("google", {
177179
api_key: "test_override_api_key",
178180
q: "coffee",
179181
});
182+
} catch {
183+
// pass
180184
} finally {
181185
executeSpy.restore();
182186
}

tests/serpapi_test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ describe("getAccount", {
9090
"extra_credits",
9191
"last_hour_searches",
9292
"plan_id",
93+
"plan_monthly_price",
9394
"plan_name",
9495
"plan_searches_left",
9596
"searches_per_month",
@@ -113,6 +114,7 @@ describe("getAccount", {
113114
"extra_credits",
114115
"last_hour_searches",
115116
"plan_id",
117+
"plan_monthly_price",
116118
"plan_name",
117119
"plan_searches_left",
118120
"searches_per_month",
@@ -135,6 +137,7 @@ describe("getAccount", {
135137
"extra_credits",
136138
"last_hour_searches",
137139
"plan_id",
140+
"plan_monthly_price",
138141
"plan_name",
139142
"plan_searches_left",
140143
"searches_per_month",

tests/utils_test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ describe("buildUrl", () => {
211211
it("with undefined parameters", async () => {
212212
assertEquals(
213213
await buildUrl("/search", { q: "coffee", gl: undefined, hl: null }),
214-
`${BASE_URL}/search?q=coffee&hl=null`,
214+
`${BASE_URL}/search?q=coffee&hl=`,
215215
);
216216
});
217217
});

0 commit comments

Comments
 (0)