-
-
Notifications
You must be signed in to change notification settings - Fork 136
feat: URL & URLSearchParams #1801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7f7a70b
feat: URL & URLSearchParams
triniwiz 7c5a136
chore: rename classes, implement createObjectURL, revokeObjectURL & u…
triniwiz 13dd73a
chore: update classname
triniwiz 08376ab
chore: format tests
triniwiz 0f61593
chore: add include license
triniwiz 54deb23
chore: format js code
triniwiz 340b571
chore: bump
triniwiz 152c1ae
release: 8.7.0-alpha.1
NathanWalker a0539cf
Merge branch 'main' into feat/ada-url-y-search-params
NathanWalker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
describe("Test URL ", function () { | ||
|
||
it("Test invalid URL parsing", function(){ | ||
var exceptionCaught = false; | ||
try { | ||
const url = new URL(''); | ||
}catch(e){ | ||
exceptionCaught = true; | ||
} | ||
expect(exceptionCaught).toBe(true); | ||
}); | ||
|
||
it("Test valid URL parsing", function(){ | ||
var exceptionCaught = false; | ||
try { | ||
const url = new URL('https://google.com'); | ||
}catch(e){ | ||
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'); | ||
}); | ||
|
||
}); |
64 changes: 64 additions & 0 deletions
64
test-app/app/src/main/assets/app/tests/testURLSearchParamsImpl.js
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another good one to run Prettier formatting on. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
describe("Test URLSearchParams ", function () { | ||
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); | ||
}); | ||
|
||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice to see tests 😍