Added more test cases for URL (#50768)

Summary:
I forgot to add toString and protocol in test cases last time when we merged this https://github.com/facebook/react-native/pull/50043

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[INTERNAL][ADDED] More Test cases

Pull Request resolved: https://github.com/facebook/react-native/pull/50768

Test Plan: Tested with yarn jest

Reviewed By: rshest, cipolleschi

Differential Revision: D73169665

Pulled By: cortinico

fbshipit-source-id: 1115c0ccce52a67663fcd60ef376ce7bde502d1f
This commit is contained in:
riteshshukla04
2025-04-17 03:18:13 -07:00
committed by Facebook GitHub Bot
parent 7ff5db3c46
commit f5ae157820
2 changed files with 6 additions and 0 deletions
@@ -53,6 +53,10 @@ describe('URL', function () {
expect(url.pathname).toBe('/docs/path');
expect(url.port).toBe('8080');
expect(url.search).toBe('?query=testQuery&key=value');
expect(url.protocol).toBe('https:');
expect(url.toString()).toBe(
'https://username:password@reactnative.dev:8080/docs/path?query=testQuery&key=value#fragment',
);
// Test searchParams
const searchParams = url.searchParams;
@@ -31,6 +31,8 @@ function URLComponent(props: Props) {
<RNTesterText testID="URL-password">{`password: ${parsedUrl.password}`}</RNTesterText>
<RNTesterText testID="URL-username">{`username: ${parsedUrl.username}`}</RNTesterText>
<RNTesterText testID="URL-pathname">{`pathname: ${parsedUrl.pathname}`}</RNTesterText>
<RNTesterText testID="URL-protocol">{`protocol: ${parsedUrl.protocol}`}</RNTesterText>
<RNTesterText testID="URL-toString">{`toString: ${parsedUrl.toString()}`}</RNTesterText>
<RNTesterText testID="URL-port">{`port: ${parsedUrl.port}`}</RNTesterText>
<RNTesterText testID="URL-search">{`search: ${parsedUrl.search}`}</RNTesterText>
<RNTesterText testID="URL-search-params">{`searchParams: ${parsedUrl.searchParams.toString()}`}</RNTesterText>