metatext-app-ios-iphone-ipad/ViewModels/Tests/ViewModelsTests/RootViewModelTests.swift

32 lines
1017 B
Swift
Raw Normal View History

2020-08-03 17:20:51 +02:00
// Copyright © 2020 Metabolist. All rights reserved.
import Combine
import CombineExpectations
2020-08-31 20:57:02 +02:00
import ServiceLayer
2020-09-01 09:33:49 +02:00
import ServiceLayerMocks
@testable import ViewModels
2020-09-05 04:31:43 +02:00
import XCTest
2020-08-03 17:20:51 +02:00
2020-11-09 07:22:20 +01:00
final 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-09-13 02:50:22 +02:00
let uuid = UUID(uuidString: "E621E1F8-C36C-495A-93FC-0C247A3E6E5F")!
2020-09-01 09:33:49 +02:00
let sut = try RootViewModel(
2020-09-13 02:50:22 +02:00
environment: .mock(uuid: { uuid }),
2020-09-01 09:33:49 +02:00
registerForRemoteNotifications: { Empty().setFailureType(to: Error.self).eraseToAnyPublisher() })
2020-09-10 06:51:31 +02:00
let recorder = sut.$navigationViewModel.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()
addIdentityViewModel.urlFieldText = "https://mastodon.social"
addIdentityViewModel.logInTapped()
2020-08-03 17:20:51 +02:00
2020-09-10 06:51:31 +02:00
let navigationViewModel = try wait(for: recorder.next(), timeout: 1)!
2020-08-03 17:20:51 +02:00
2020-09-10 06:51:31 +02:00
XCTAssertNotNil(navigationViewModel)
2020-08-03 17:20:51 +02:00
}
}