2020-08-03 15:20:51 +00:00
|
|
|
// Copyright © 2020 Metabolist. All rights reserved.
|
|
|
|
|
|
|
|
import XCTest
|
|
|
|
import Combine
|
|
|
|
import CombineExpectations
|
|
|
|
@testable import Metatext
|
|
|
|
|
|
|
|
class RootViewModelTests: XCTestCase {
|
2020-08-07 01:41:59 +00:00
|
|
|
var cancellables = Set<AnyCancellable>()
|
|
|
|
|
2020-08-03 15:20:51 +00:00
|
|
|
func testAddIdentity() throws {
|
2020-08-12 07:24:39 +00:00
|
|
|
let sut = RootViewModel(appDelegate: AppDelegate(),
|
2020-08-26 21:35:06 +00:00
|
|
|
allIdentitiesService: AllIdentitiesService(
|
2020-08-09 11:27:38 +00:00
|
|
|
identityDatabase: .fresh(),
|
2020-08-12 07:24:39 +00:00
|
|
|
environment: .development),
|
2020-08-14 01:24:53 +00:00
|
|
|
userNotificationService: UserNotificationService())
|
2020-08-27 04:25:28 +00:00
|
|
|
let recorder = sut.$tabNavigationViewModel.record()
|
2020-08-03 15:20:51 +00:00
|
|
|
|
2020-08-04 20:26:09 +00:00
|
|
|
XCTAssertNil(try wait(for: recorder.next(), timeout: 1))
|
2020-08-03 15:20:51 +00:00
|
|
|
|
|
|
|
let addIdentityViewModel = sut.addIdentityViewModel()
|
|
|
|
|
2020-08-14 01:59:17 +00:00
|
|
|
addIdentityViewModel.addedIdentityID
|
|
|
|
.sink(receiveValue: sut.newIdentitySelected(id:))
|
2020-08-07 01:41:59 +00:00
|
|
|
.store(in: &cancellables)
|
|
|
|
|
2020-08-03 15:20:51 +00:00
|
|
|
addIdentityViewModel.urlFieldText = "https://mastodon.social"
|
2020-08-09 11:27:38 +00:00
|
|
|
addIdentityViewModel.logInTapped()
|
2020-08-03 15:20:51 +00:00
|
|
|
|
2020-08-09 05:37:04 +00:00
|
|
|
let mainNavigationViewModel = try wait(for: recorder.next(), timeout: 1)!
|
2020-08-03 15:20:51 +00:00
|
|
|
|
2020-08-09 05:37:04 +00:00
|
|
|
XCTAssertNotNil(mainNavigationViewModel)
|
2020-08-03 15:20:51 +00:00
|
|
|
}
|
|
|
|
}
|