Skip to content

Commit 9925fcd

Browse files
committed
URL: tests for URL.parse()
As per whatwg/url#372.
1 parent c726644 commit 9925fcd

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

url/url-statics-parse.any.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// This intentionally does not use resources/urltestdata.json to preserve resources.
2+
[
3+
{
4+
"url": undefined,
5+
"base": undefined,
6+
"expected": false
7+
},
8+
{
9+
"url": "aaa:b",
10+
"base": undefined,
11+
"expected": true
12+
},
13+
{
14+
"url": undefined,
15+
"base": "aaa:b",
16+
"expected": false
17+
},
18+
{
19+
"url": "aaa:/b",
20+
"base": undefined,
21+
"expected": true
22+
},
23+
{
24+
"url": undefined,
25+
"base": "aaa:/b",
26+
"expected": true
27+
},
28+
{
29+
"url": "https://test:test",
30+
"base": undefined,
31+
"expected": false
32+
},
33+
{
34+
"url": "a",
35+
"base": "https://b/",
36+
"expected": true
37+
}
38+
].forEach(({ url, base, expected }) => {
39+
test(() => {
40+
if (expected == false) {
41+
assert_equals(URL.parse(url, base), null);
42+
} else {
43+
assert_equals(URL.parse(url, base).href = new URL(url, base).href);
44+
}
45+
}, `URL.parse(${url}, ${base})`);
46+
});
47+
48+
test(() => {
49+
assert_not_equals(URL.parse("https://example/"), URL.parse("https://example/"));
50+
}, `URL.parse() should return a unique object`);

0 commit comments

Comments
 (0)