Revision control
Copy as Markdown
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
import XCTest
#if FOCUS
@testable import Firefox_Focus
#else
@testable import Firefox_Klar
#endif
class URIFixupTests: XCTestCase {
private let customSchemeURLs = ["firefox://",
"mailto:jsmith@example.com",
"http:// shouldfail.com",
"mo zilla.com",
"www.firefox .com",
"mozilla",
":/#?&@%+~" // test failing on iOS 17
]
func testValidURLsForHttpAndHttpsSchemes() {
httpSchemeURLs.forEach {
XCTAssertNotNil(URIFixup.getURL(entry: $0), "\($0) is not a valid URL")
let httpsSchemeURL = $0.replacingOccurrences(of: "http", with: "https")
XCTAssertNotNil(URIFixup.getURL(entry: httpsSchemeURL), "\(httpsSchemeURL) is not a valid URL")
}
}
func testCustomSchemes() {
customSchemeURLs.forEach {
XCTAssertNotNil(URIFixup.getURL(entry: $0), "\($0) is not a valid URL")
}
}
func testInvalidURLs() {
invalidURLs.forEach {
XCTAssertNil(URIFixup.getURL(entry: $0), "\($0) is a valid URL")
}
}
}