Skip to content

Commit f17892e

Browse files
committed
chore: format tests
1 parent 49ce958 commit f17892e

File tree

2 files changed

+67
-59
lines changed

2 files changed

+67
-59
lines changed
Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
describe("Test URL ", function () {
22

3-
it("Test invalid URL parsing", function(){
4-
var exceptionCaught = false;
5-
try {
6-
const url = new URL('');
3+
it("Test invalid URL parsing", function(){
4+
var exceptionCaught = false;
5+
try {
6+
const url = new URL('');
77
}catch(e){
8-
exceptionCaught = true;
8+
exceptionCaught = true;
99
}
1010
expect(exceptionCaught).toBe(true);
11-
});
11+
});
1212

13-
it("Test valid URL parsing", function(){
14-
var exceptionCaught = false;
15-
try {
16-
const url = new URL('https://google.com');
13+
it("Test valid URL parsing", function(){
14+
var exceptionCaught = false;
15+
try {
16+
const url = new URL('https://google.com');
1717
}catch(e){
18-
exceptionCaught = true;
18+
exceptionCaught = true;
1919
}
2020
expect(exceptionCaught).toBe(false);
21-
});
21+
});
2222

2323

24-
it("Test URL fields", function(){
25-
var exceptionCaught = false;
26-
const url = new URL('https://google.com');
27-
expect(url.protocol).toBe('https:');
28-
expect(url.hostname).toBe('google.com');
29-
});
24+
it("Test URL fields", function(){
25+
var exceptionCaught = false;
26+
const url = new URL('https://google.com');
27+
expect(url.protocol).toBe('https:');
28+
expect(url.hostname).toBe('google.com');
29+
});
3030

31-
});
31+
});

test-app/app/src/main/assets/app/tests/testURLSearchParamsImpl.js

Lines changed: 48 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,64 @@
11
describe("Test URLSearchParams ", function () {
2+
const fooBar = "foo=1&bar=2";
3+
it("Test URLSearchParams keys", function(){
4+
const params = new URLSearchParams(fooBar);
5+
const keys = params.keys();
6+
expect(keys[0]).toBe("foo");
7+
expect(keys[1]).toBe("bar");
8+
});
29

10+
it("Test URLSearchParams values", function(){
11+
const params = new URLSearchParams(fooBar);
12+
const values = params.values();
13+
expect(values[0]).toBe("1");
14+
expect(values[1]).toBe("2");
15+
});
316

4-
it("Test URLSearchParams keys", function(){
5-
const params = new URLSearchParams("foo=1&bar=2");
6-
const keys = params.keys();
7-
expect(keys[0]).toBe("foo");
8-
expect(keys[1]).toBe("bar");
9-
});
1017

11-
it("Test URLSearchParams values", function(){
12-
const params = new URLSearchParams("foo=1&bar=2");
13-
const values = params.values();
14-
expect(values[0]).toBe("1");
15-
expect(values[1]).toBe("2");
16-
});
18+
it("Test URLSearchParams entries", function(){
19+
const params = new URLSearchParams(fooBar);
20+
const entries = params.entries();
21+
expect(entries[0][0]).toBe("foo");
22+
expect(entries[0][1]).toBe("1");
1723

24+
expect(entries[1][0]).toBe("bar");
25+
expect(entries[1][1]).toBe("2");
1826

19-
it("Test URLSearchParams entries", function(){
20-
const params = new URLSearchParams("foo=1&bar=2");
21-
const entries = params.entries();
22-
expect(entries[0][0]).toBe("foo");
23-
expect(entries[0][1]).toBe("1");
27+
});
2428

25-
expect(entries[1][0]).toBe("bar");
26-
expect(entries[1][1]).toBe("2");
2729

28-
});
30+
it("Test URLSearchParams size", function(){
31+
const params = new URLSearchParams(fooBar);
32+
expect(params.size).toBe(2);
33+
});
2934

35+
it("Test URLSearchParams append", function(){
36+
const params = new URLSearchParams(fooBar);
37+
params.append("first", "Osei");
38+
expect(params.get("first")).toBe("Osei");
39+
});
3040

31-
it("Test URLSearchParams size", function(){
32-
const params = new URLSearchParams("foo=1&bar=2");
33-
expect(params.size).toBe(2);
34-
});
3541

36-
it("Test URLSearchParams append", function(){
37-
const params = new URLSearchParams("foo=1&bar=2");
38-
params.append("first", "Osei");
39-
expect(params.get("first")).toBe("Osei");
40-
});
42+
it("Test URLSearchParams delete", function(){
43+
const params = new URLSearchParams(fooBar);
44+
params.append("first", "Osei");
45+
params.delete("first");
46+
expect(params.get("first")).toBe(undefined);
47+
});
4148

4249

43-
it("Test URLSearchParams delete", function(){
44-
const params = new URLSearchParams("foo=1&bar=2");
45-
params.append("first", "Osei");
46-
params.delete("first");
47-
expect(params.get("first")).toBe(undefined);
48-
});
50+
it("Test URLSearchParams has", function(){
51+
const params = new URLSearchParams(fooBar);
52+
expect(params.has("foo")).toBe(true);
53+
});
4954

55+
it("Test URLSearchParams changes propagates to URL parent", function(){
56+
const toBe = 'https://github.com/triniwiz?first=Osei';
57+
const url = new URL('https://github.com/triniwiz');
58+
const params = url.searchParams;
59+
console.log(params);
60+
params.set('first', 'Osei');
61+
expect(url.toString()).toBe(toBe);
62+
});
5063

51-
it("Test URLSearchParams has", function(){
52-
const params = new URLSearchParams("foo=1&bar=2");
53-
expect(params.has("foo")).toBe(true);
5464
});
55-
56-
});

0 commit comments

Comments
 (0)