2020-08-03 17:20:51 +02:00
|
|
|
// Copyright © 2020 Metabolist. All rights reserved.
|
|
|
|
|
|
|
|
import XCTest
|
|
|
|
import Combine
|
|
|
|
import CombineExpectations
|
|
|
|
@testable import Metatext
|
|
|
|
|
|
|
|
class RootViewModelTests: XCTestCase {
|
2020-08-07 03:41:59 +02:00
|
|
|
var cancellables = Set<AnyCancellable>()
|
|
|
|
|
2020-08-03 17:20:51 +02:00
|
|
|
func testAddIdentity() throws {
|
2020-08-09 07:37:04 +02:00
|
|
|
let environment = AppEnvironment.fresh()
|
|
|
|
let sut = RootViewModel(
|
|
|
|
identitiesService: IdentitiesService(environment: environment))
|
|
|
|
let recorder = sut.$mainNavigationViewModel.record()
|
2020-08-03 17:20:51 +02:00
|
|
|
|
2020-08-04 22:26:09 +02:00
|
|
|
XCTAssertNil(try wait(for: recorder.next(), timeout: 1))
|
2020-08-03 17:20:51 +02:00
|
|
|
|
|
|
|
let addIdentityViewModel = sut.addIdentityViewModel()
|
|
|
|
|
2020-08-07 03:41:59 +02:00
|
|
|
addIdentityViewModel.addedIdentityID
|
|
|
|
.sink(receiveValue: sut.newIdentitySelected(id:))
|
|
|
|
.store(in: &cancellables)
|
|
|
|
|
2020-08-03 17:20:51 +02:00
|
|
|
addIdentityViewModel.urlFieldText = "https://mastodon.social"
|
|
|
|
addIdentityViewModel.goTapped()
|
|
|
|
|
2020-08-09 07:37:04 +02:00
|
|
|
let mainNavigationViewModel = try wait(for: recorder.next(), timeout: 1)!
|
2020-08-03 17:20:51 +02:00
|
|
|
|
2020-08-09 07:37:04 +02:00
|
|
|
XCTAssertNotNil(mainNavigationViewModel)
|
2020-08-03 17:20:51 +02:00
|
|
|
}
|
|
|
|
}
|