-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.setup.js
More file actions
38 lines (37 loc) · 869 Bytes
/
Copy pathjest.setup.js
File metadata and controls
38 lines (37 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Mock process.env for tests
process.env.NEXT_PUBLIC_APP_BASE_URL = "http://localhost:3000";
process.env.NEXT_PUBLIC_TEST_URL = "http://localhost:3000";
// Mock URLSearchParams
global.URLSearchParams = class URLSearchParams {
constructor() {
this.params = new Map();
}
append(key, value) {
this.params.set(key, value);
}
delete(key) {
this.params.delete(key);
}
get(key) {
return this.params.get(key);
}
getAll(key) {
return Array.from(this.params.entries())
.filter(([k]) => k === key)
.map(([, v]) => v);
}
has(key) {
return this.params.has(key);
}
set(key, value) {
this.params.set(key, value);
}
toString() {
return Array.from(this.params.entries())
.map(
([key, value]) =>
`${encodeURIComponent(key)}=${encodeURIComponent(value)}`
)
.join("&");
}
};