1
0
mirror of https://github.com/metabolist/metatext synced 2024-12-12 17:36:09 +01:00
metatext-app-ios-iphone-ipad/ViewModels/Tests/ViewModelsTests/RootViewModelTests.swift
Justin Mazzocchi b4549521cb
Refactoring
2020-09-07 19:12:38 -07:00

35 lines
1.0 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.$identification.record()
XCTAssertNil(try wait(for: recorder.next(), timeout: 1))
let addIdentityViewModel = sut.addIdentityViewModel()
addIdentityViewModel.addedIdentityID
.sink(receiveValue: sut.newIdentitySelected(id:))
.store(in: &cancellables)
addIdentityViewModel.urlFieldText = "https://mastodon.social"
addIdentityViewModel.logInTapped()
let mainNavigationViewModel = try wait(for: recorder.next(), timeout: 1)!
XCTAssertNotNil(mainNavigationViewModel)
}
}