Skip to content

Commit 594d491

Browse files
committed
test(URL): add parse and canParse polyfills
1 parent 6d2b4de commit 594d491

File tree

4 files changed

+648
-821
lines changed

4 files changed

+648
-821
lines changed

.github/dependency-review/dependency-review-config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ allow-licenses:
1515
- 'ISC'
1616
- 'JSON'
1717
- 'MIT'
18+
- 'MIT-0'
1819
- 'OpenSSL'
1920
- 'PDDL-1.0'
2021
- 'PostgreSQL'

jest.setup.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,26 @@ global.console = {
1111

1212
// React Native global
1313
global['__DEV__'] = true;
14+
15+
/* this is available according to
16+
https://developer.mozilla.org/en-US/docs/Web/API/URL
17+
18+
for react-native use:
19+
import { loadUrlPolyfill } from '@aws-amplify/react-native';
20+
*/
21+
Object.defineProperty(URL, 'parse', {
22+
value: (path, origin) => {
23+
try {
24+
return new URL(path, origin);
25+
} catch {
26+
return null;
27+
}
28+
},
29+
});
30+
31+
Object.defineProperty(URL, 'canParse', {
32+
value: (path, origin) => {
33+
const out = URL.parse(path, origin);
34+
return null !== out;
35+
},
36+
});

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,11 @@
106106
"eslint-plugin-prettier": "^5.2.1",
107107
"eslint-plugin-promise": "^7.1.0",
108108
"eslint-plugin-unused-imports": "^4.1.4",
109-
"expect": "^30.0.5",
109+
"expect": "^29.7.0",
110110
"glob": "^10.3.10",
111111
"husky": "^9.0.11",
112-
"jest": "^30.0.5",
113-
"jest-environment-jsdom": "^30.0.5",
112+
"jest": "^29.7.0",
113+
"jest-environment-jsdom": "^29.7.0",
114114
"json-loader": "^0.5.7",
115115
"lerna": "^8.2.1",
116116
"license-check-and-add": "^4.0.5",

0 commit comments

Comments
 (0)