Skip to content

Commit

Permalink
Add more tests for the AppRouteURLParser
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanceriu committed Sep 25, 2023
1 parent 01d7134 commit 356a316
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions UnitTests/Sources/AppRouteURLParserTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit 356a316

Please sign in to comment.