metatext-app-ios-iphone-ipad/ServiceLayer/Tests/ServiceLayerTests/InstanceURLServiceTests.swift

38 lines
1012 B
Swift
Raw Normal View History

2020-09-07 06:56:18 +02:00
// Copyright © 2020 Metabolist. All rights reserved.
import CodableBloomFilter
import Combine
import CombineExpectations
@testable import ServiceLayer
@testable import ServiceLayerMocks
import Stubbing
import XCTest
2020-11-09 07:22:20 +01:00
final class InstanceURLServiceTests: XCTestCase {
2020-09-07 06:56:18 +02:00
func testFiltering() throws {
2020-09-10 06:51:31 +02:00
let sut = InstanceURLService(environment: .mock())
2020-09-07 06:56:18 +02:00
2021-01-17 21:24:50 +01:00
guard case .success = sut.url(text: "unfiltered.instance") else {
2020-09-23 09:11:35 +02:00
XCTFail("Expected success")
2021-01-17 21:24:50 +01:00
return
2020-09-23 09:11:35 +02:00
}
2021-01-17 21:24:50 +01:00
guard case let .failure(error) = sut.url(text: "filtered.instance"),
case InstanceURLError.instanceNotSupported = error
else {
XCTFail("Expected instance not supported error")
return
2020-09-23 09:11:35 +02:00
}
2021-01-17 21:24:50 +01:00
guard case .failure = sut.url(text: "subdomain.filtered.instance"),
case InstanceURLError.instanceNotSupported = error
else {
XCTFail("Expected instance not supported error")
return
2020-09-23 09:11:35 +02:00
}
2020-09-07 06:56:18 +02:00
}
}