Skip to content

Commit 23e145a

Browse files
committed
Improve tests
Signed-off-by: Cintia Sánchez García <[email protected]>
1 parent c54d9fa commit 23e145a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

web/src/setupTests.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,26 @@ import { vi } from 'vitest';
66

77
process.env.TZ = 'UTC';
88

9+
const urlPathnameDescriptor = Object.getOwnPropertyDescriptor(URL.prototype, 'pathname');
10+
if (urlPathnameDescriptor?.get) {
11+
Object.defineProperty(URL.prototype, 'pathname', {
12+
configurable: true,
13+
enumerable: urlPathnameDescriptor.enumerable ?? true,
14+
get() {
15+
const value = urlPathnameDescriptor.get!.call(this);
16+
if (typeof value === 'string' && value.startsWith('/media/')) {
17+
return `/src${value}`;
18+
}
19+
return value;
20+
},
21+
set(newValue) {
22+
if (urlPathnameDescriptor.set) {
23+
urlPathnameDescriptor.set.call(this, newValue);
24+
}
25+
},
26+
});
27+
}
28+
929
const require = createRequire(import.meta.url);
1030

1131
const noop = () => {};

0 commit comments

Comments
 (0)