mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-26 10:10:58 +00:00
34 lines
1 KiB
Swift
34 lines
1 KiB
Swift
// Copyright © 2020 Metabolist. All rights reserved.
|
|
|
|
import Combine
|
|
import CombineExpectations
|
|
import ServiceLayer
|
|
import ServiceLayerMocks
|
|
@testable import ViewModels
|
|
import XCTest
|
|
|
|
class RootViewModelTests: XCTestCase {
|
|
var cancellables = Set<AnyCancellable>()
|
|
|
|
func testAddIdentity() throws {
|
|
let sut = try RootViewModel(
|
|
environment: .mock(),
|
|
registerForRemoteNotifications: { Empty().setFailureType(to: Error.self).eraseToAnyPublisher() })
|
|
let recorder = sut.$navigationViewModel.record()
|
|
|
|
XCTAssertNil(try wait(for: recorder.next(), timeout: 1))
|
|
|
|
let addIdentityViewModel = sut.addIdentityViewModel()
|
|
|
|
addIdentityViewModel.addedIdentityID
|
|
.sink(receiveValue: sut.identitySelected(id:))
|
|
.store(in: &cancellables)
|
|
|
|
addIdentityViewModel.urlFieldText = "https://mastodon.social"
|
|
addIdentityViewModel.logInTapped()
|
|
|
|
let navigationViewModel = try wait(for: recorder.next(), timeout: 1)!
|
|
|
|
XCTAssertNotNil(navigationViewModel)
|
|
}
|
|
}
|