From f5ae1578208dd1afaa3fdd39d9bf897ef2d3cac1 Mon Sep 17 00:00:00 2001 From: riteshshukla04 Date: Thu, 17 Apr 2025 03:18:13 -0700 Subject: [PATCH] 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: [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 --- packages/react-native/Libraries/Blob/__tests__/URL-test.js | 4 ++++ packages/rn-tester/js/examples/Urls/UrlExample.js | 2 ++ 2 files changed, 6 insertions(+) diff --git a/packages/react-native/Libraries/Blob/__tests__/URL-test.js b/packages/react-native/Libraries/Blob/__tests__/URL-test.js index 0eb4d06a1ac..9dbf8c6a6ca 100644 --- a/packages/react-native/Libraries/Blob/__tests__/URL-test.js +++ b/packages/react-native/Libraries/Blob/__tests__/URL-test.js @@ -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; diff --git a/packages/rn-tester/js/examples/Urls/UrlExample.js b/packages/rn-tester/js/examples/Urls/UrlExample.js index 0e29aaeee72..a54c87837db 100644 --- a/packages/rn-tester/js/examples/Urls/UrlExample.js +++ b/packages/rn-tester/js/examples/Urls/UrlExample.js @@ -31,6 +31,8 @@ function URLComponent(props: Props) { {`password: ${parsedUrl.password}`} {`username: ${parsedUrl.username}`} {`pathname: ${parsedUrl.pathname}`} + {`protocol: ${parsedUrl.protocol}`} + {`toString: ${parsedUrl.toString()}`} {`port: ${parsedUrl.port}`} {`search: ${parsedUrl.search}`} {`searchParams: ${parsedUrl.searchParams.toString()}`}