Skip to content

Commit

Permalink
chore: format tests
Browse files Browse the repository at this point in the history
  • Loading branch information
triniwiz committed Jan 20, 2024
1 parent 7b26808 commit 1885097
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 77 deletions.
46 changes: 23 additions & 23 deletions TestRunner/app/tests/URL.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
describe("Test URL ", function () {

it("Test invalid URL parsing", function(){
var exceptionCaught = false;
try {
const url = new URL('');
it("Test invalid URL parsing", function(){
var exceptionCaught = false;
try {
const url = new URL('');
}catch(e){
exceptionCaught = true;
exceptionCaught = true;
}
expect(exceptionCaught).toBe(true);
});

it("Test valid URL parsing", function(){
var exceptionCaught = false;
try {
const url = new URL('https://google.com');
});
it("Test valid URL parsing", function(){
var exceptionCaught = false;
try {
const url = new URL('https://google.com');
}catch(e){
exceptionCaught = true;
exceptionCaught = true;
}
expect(exceptionCaught).toBe(false);
});


it("Test URL fields", function(){
var exceptionCaught = false;
const url = new URL('https://google.com');
expect(url.protocol).toBe('https:');
expect(url.hostname).toBe('google.com');
});

});
it("Test URL fields", function(){
var exceptionCaught = false;
const url = new URL('https://google.com');
expect(url.protocol).toBe('https:');
expect(url.hostname).toBe('google.com');
});
});
116 changes: 62 additions & 54 deletions TestRunner/app/tests/URLSearchParams.js
Original file line number Diff line number Diff line change
@@ -1,56 +1,64 @@
describe("Test URLSearchParams ", function () {


it("Test URLSearchParams keys", function(){
const params = new URLSearchParams("foo=1&bar=2");
const keys = params.keys();
expect(keys[0]).toBe("foo");
expect(keys[1]).toBe("bar");
});

it("Test URLSearchParams values", function(){
const params = new URLSearchParams("foo=1&bar=2");
const values = params.values();
expect(values[0]).toBe("1");
expect(values[1]).toBe("2");
});


it("Test URLSearchParams entries", function(){
const params = new URLSearchParams("foo=1&bar=2");
const entries = params.entries();
expect(entries[0][0]).toBe("foo");
expect(entries[0][1]).toBe("1");

expect(entries[1][0]).toBe("bar");
expect(entries[1][1]).toBe("2");

});


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

it("Test URLSearchParams append", function(){
const params = new URLSearchParams("foo=1&bar=2");
params.append("first", "Osei");
expect(params.get("first")).toBe("Osei");
});


it("Test URLSearchParams delete", function(){
const params = new URLSearchParams("foo=1&bar=2");
params.append("first", "Osei");
params.delete("first");
expect(params.get("first")).toBe(undefined);
});


it("Test URLSearchParams has", function(){
const params = new URLSearchParams("foo=1&bar=2");
expect(params.has("foo")).toBe(true);
});

const fooBar = "foo=1&bar=2";
it("Test URLSearchParams keys", function(){
const params = new URLSearchParams(fooBar);
const keys = params.keys();
expect(keys[0]).toBe("foo");
expect(keys[1]).toBe("bar");
});

it("Test URLSearchParams values", function(){
const params = new URLSearchParams(fooBar);
const values = params.values();
expect(values[0]).toBe("1");
expect(values[1]).toBe("2");
});


it("Test URLSearchParams entries", function(){
const params = new URLSearchParams(fooBar);
const entries = params.entries();
expect(entries[0][0]).toBe("foo");
expect(entries[0][1]).toBe("1");

expect(entries[1][0]).toBe("bar");
expect(entries[1][1]).toBe("2");

});


it("Test URLSearchParams size", function(){
const params = new URLSearchParams(fooBar);
expect(params.size).toBe(2);
});

it("Test URLSearchParams append", function(){
const params = new URLSearchParams(fooBar);
params.append("first", "Osei");
expect(params.get("first")).toBe("Osei");
});


it("Test URLSearchParams delete", function(){
const params = new URLSearchParams(fooBar);
params.append("first", "Osei");
params.delete("first");
expect(params.get("first")).toBe(undefined);
});


it("Test URLSearchParams has", function(){
const params = new URLSearchParams(fooBar);
expect(params.has("foo")).toBe(true);
});

it("Test URLSearchParams changes propagates to URL parent", function(){
const toBe = 'https://github.com/triniwiz?first=Osei';
const url = new URL('https://github.com/triniwiz');
const params = url.searchParams;
console.log(params);
params.set('first', 'Osei');
expect(url.toString()).toBe(toBe);
});

});

0 comments on commit 1885097

Please sign in to comment.