From 274769fd8c5976f0163d0a729abf562c48ed15ea Mon Sep 17 00:00:00 2001 From: Nick Lockwood Date: Tue, 4 Aug 2015 16:18:03 -0700 Subject: [PATCH] Added Unicode URL test --- .../UIExplorerUnitTests/RCTConvert_NSURLTests.m | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Examples/UIExplorer/UIExplorerUnitTests/RCTConvert_NSURLTests.m b/Examples/UIExplorer/UIExplorerUnitTests/RCTConvert_NSURLTests.m index 781a13d60..a42d587b0 100644 --- a/Examples/UIExplorer/UIExplorerUnitTests/RCTConvert_NSURLTests.m +++ b/Examples/UIExplorer/UIExplorerUnitTests/RCTConvert_NSURLTests.m @@ -26,8 +26,7 @@ #define TEST_URL(name, _input, _expectedURL) \ - (void)test_##name { \ NSURL *result = [RCTConvert NSURL:_input]; \ - NSURL *expected = (_expectedURL) ? [NSURL URLWithString:_expectedURL ?: @""] : nil; \ - XCTAssertEqualObjects(result.absoluteURL, expected); \ + XCTAssertEqualObjects(result.absoluteString, _expectedURL); \ } \ #define TEST_PATH(name, _input, _expectedPath) \ @@ -52,7 +51,9 @@ TEST_BUNDLE_PATH(imageAt2XPath, @"images/foo@2x.jpg", @"images/foo@2x.jpg") TEST_BUNDLE_PATH(imageFile, @"foo.jpg", @"foo.jpg") // User documents -TEST_PATH(documentsFolder, @"~/Documents", [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]) +TEST_PATH(documentsFolder, @"~/Documents", + [NSSearchPathForDirectoriesInDomains + (NSDocumentDirectory, NSUserDomainMask, YES) firstObject]) // Remote files TEST_URL(fullURL, @"http://example.com/blah/hello.jsbundle", @"http://example.com/blah/hello.jsbundle") @@ -61,6 +62,13 @@ TEST_URL(urlWithEncodedSpaces, @"http://example.com/blah%20blah/foo", @"http://e TEST_URL(imageURL, @"http://example.com/foo@2x.jpg", @"http://example.com/foo@2x.jpg") TEST_URL(imageURLWithSpaces, @"http://example.com/blah foo@2x.jpg", @"http://example.com/blah%20foo@2x.jpg") +// Unicode +TEST_URL(unicodeURL, + @"https://ru.wikipedia.org/wiki/\u0417\u0430\u0433\u043B\u0430\u0432" + "\u043D\u0430\u044F_\u0441\u0442\u0440\u0430\u043D\u0438\u0446\u0430", + @"https://ru.wikipedia.org/wiki/%D0%97%D0%B0%D0%B3%D0%BB%D0%B0%D0%B2" + "%D0%BD%D0%B0%D1%8F_%D1%81%D1%82%D1%80%D0%B0%D0%BD%D0%B8%D1%86%D0%B0") + // Data URLs - (void)testDataURL {