mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-29 03:21:02 +00:00
update tests
This commit is contained in:
parent
3c46c6185d
commit
5fa4fb1b76
1 changed files with 10 additions and 15 deletions
|
@ -11,23 +11,18 @@ import XCTest
|
||||||
class InstanceURLServiceTests: XCTestCase {
|
class InstanceURLServiceTests: XCTestCase {
|
||||||
func testFiltering() throws {
|
func testFiltering() throws {
|
||||||
let sut = InstanceURLService(environment: .mock())
|
let sut = InstanceURLService(environment: .mock())
|
||||||
let unfilteredInstanceURL = URL(string: "https://unfiltered.instance")!
|
|
||||||
let filteredInstanceURL = URL(string: "https://filtered.instance")!
|
|
||||||
let subdomainFilteredInstanceURL = URL(string: "https://subdomain.filtered.instance")!
|
|
||||||
|
|
||||||
XCTAssertFalse(sut.isFiltered(url: unfilteredInstanceURL))
|
XCTAssertNotNil(sut.url(text: "unfiltered.instance"))
|
||||||
XCTAssertTrue(sut.isFiltered(url: filteredInstanceURL))
|
XCTAssertNil(sut.url(text: "filtered.instance"))
|
||||||
XCTAssertTrue(sut.isFiltered(url: subdomainFilteredInstanceURL))
|
XCTAssertNil(sut.url(text: "subdomain.filtered.instance"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func testUpdating() throws {
|
func testUpdating() throws {
|
||||||
let environment = AppEnvironment.mock()
|
let environment = AppEnvironment.mock()
|
||||||
var sut = InstanceURLService(environment: environment)
|
var sut = InstanceURLService(environment: environment)
|
||||||
let previouslyFilteredInstanceURL = URL(string: "https://filtered.instance")!
|
|
||||||
let newlyFilteredInstanceURL = URL(string: "https://instance.filtered")!
|
|
||||||
|
|
||||||
XCTAssertTrue(sut.isFiltered(url: previouslyFilteredInstanceURL))
|
XCTAssertNil(sut.url(text: "filtered.instance"))
|
||||||
XCTAssertFalse(sut.isFiltered(url: newlyFilteredInstanceURL))
|
XCTAssertNotNil(sut.url(text: "instance.filtered"))
|
||||||
|
|
||||||
var updatedFilter = try BloomFilter<String>(hashes: [.djb232, .sdbm32], byteCount: 16)
|
var updatedFilter = try BloomFilter<String>(hashes: [.djb232, .sdbm32], byteCount: 16)
|
||||||
|
|
||||||
|
@ -36,18 +31,18 @@ class InstanceURLServiceTests: XCTestCase {
|
||||||
let updatedFilterData = try JSONEncoder().encode(updatedFilter)
|
let updatedFilterData = try JSONEncoder().encode(updatedFilter)
|
||||||
let stub: HTTPStub = .success((URLResponse(), updatedFilterData))
|
let stub: HTTPStub = .success((URLResponse(), updatedFilterData))
|
||||||
|
|
||||||
StubbingURLProtocol.setStub(stub, forURL: URL(string: "https://filter.metabolist.com/filter.json")!)
|
StubbingURLProtocol.setStub(stub, forURL: URL(string: "https://filter.metabolist.com/filter")!)
|
||||||
|
|
||||||
let updateRecorder = sut.updateFilter().collect().record()
|
let updateRecorder = sut.updateFilter().collect().record()
|
||||||
|
|
||||||
_ = try wait(for: updateRecorder.next(), timeout: 1)
|
_ = try wait(for: updateRecorder.next(), timeout: 1)
|
||||||
|
|
||||||
XCTAssertFalse(sut.isFiltered(url: previouslyFilteredInstanceURL))
|
XCTAssertNotNil(sut.url(text: "filtered.instance"))
|
||||||
XCTAssertTrue(sut.isFiltered(url: newlyFilteredInstanceURL))
|
XCTAssertNil(sut.url(text: "instance.filtered"))
|
||||||
|
|
||||||
sut = InstanceURLService(environment: environment)
|
sut = InstanceURLService(environment: environment)
|
||||||
|
|
||||||
XCTAssertFalse(sut.isFiltered(url: previouslyFilteredInstanceURL))
|
XCTAssertNotNil(sut.url(text: "filtered.instance"))
|
||||||
XCTAssertTrue(sut.isFiltered(url: newlyFilteredInstanceURL))
|
XCTAssertNil(sut.url(text: "instance.filtered"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue