mirror of
https://github.com/bitwarden/ios.git
synced 2026-04-13 01:13:26 -05:00
28 lines
1.0 KiB
Swift
28 lines
1.0 KiB
Swift
import BitwardenKit
|
|
import Combine
|
|
import XCTest
|
|
|
|
class StringExtensionsTests: BitwardenTestCase {
|
|
// MARK: Tests
|
|
|
|
/// `fixURLIfNeeded()` returns the same string when it can be directly converted to `URL`.
|
|
func test_fixURLIfNeeded_sameStringWhenCanConvertToURL() {
|
|
let string = "https://bitwarden.com"
|
|
XCTAssertEqual(string.fixURLIfNeeded(), "https://bitwarden.com")
|
|
}
|
|
|
|
/// `fixURLIfNeeded()` returns the same string prefixed with "http://" when it can't be
|
|
/// directly converted to `URL` and it's an IP address.
|
|
func test_fixURLIfNeeded_httpWhenIPAddress() {
|
|
let string = "192.168.0.1:8080"
|
|
XCTAssertEqual(string.fixURLIfNeeded(), "http://192.168.0.1:8080")
|
|
}
|
|
|
|
/// `fixURLIfNeeded()` returns the same string prefixed with "https://" when it can't be
|
|
/// directly converted to `URL` and it's not an IP address.
|
|
func test_fixURLIfNeeded_httpsWhenNotIPAddress() {
|
|
let string = "ht tp://broken.com"
|
|
XCTAssertEqual(string.fixURLIfNeeded(), "https://ht tp://broken.com")
|
|
}
|
|
}
|