From 356a3167f0c2091d14e01392f9fa0bd8b7cfea52 Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Mon, 25 Sep 2023 09:18:46 +0300 Subject: [PATCH] Add more tests for the AppRouteURLParser --- .../Sources/AppRouteURLParserTests.swift | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/UnitTests/Sources/AppRouteURLParserTests.swift b/UnitTests/Sources/AppRouteURLParserTests.swift index f8dd886e9d..89159b12d7 100644 --- a/UnitTests/Sources/AppRouteURLParserTests.swift +++ b/UnitTests/Sources/AppRouteURLParserTests.swift @@ -34,4 +34,42 @@ class AppRouteURLParserTests: XCTestCase { XCTAssertEqual(AppRouteURLParser(appSettings: ServiceLocator.shared.settings).route(from: customSchemeURL), AppRoute.genericCallLink(url: url)) } + + func testCustomDomainUniversalLinkCallRoutes() { + guard let url = URL(string: "https://somecustomdomain.element.io/test") else { + XCTFail("URL invalid") + return + } + + XCTAssertEqual(AppRouteURLParser(appSettings: ServiceLocator.shared.settings).route(from: url), nil) + } + + func testCustomSchemeLinkCallRoutes() { + let urlString = "https://somecustomdomain.element.io/test?param=123" + guard let url = URL(string: urlString) else { + XCTFail("URL invalid") + return + } + + guard let encodedURLString = urlString.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed) else { + XCTFail("Could not encode URL string") + return + } + + guard let customSchemeURL = URL(string: "io.element.call:/?url=\(encodedURLString)") else { + XCTFail("URL invalid") + return + } + + XCTAssertEqual(AppRouteURLParser(appSettings: ServiceLocator.shared.settings).route(from: customSchemeURL), AppRoute.genericCallLink(url: url)) + } + + func testHttpCustomSchemeLinkCallRoutes() { + guard let customSchemeURL = URL(string: "io.element.call:/?url=http%3A%2F%2Fcall.element.io%2Ftest") else { + XCTFail("URL invalid") + return + } + + XCTAssertEqual(AppRouteURLParser(appSettings: ServiceLocator.shared.settings).route(from: customSchemeURL), nil) + } }