metatext/ViewModels/Tests/ViewModelsTests/RootViewModelTests.swift
Justin Mazzocchi 62ddaac083
Refactoring
2020-09-12 17:50:22 -07:00

31 lines
1,011 B
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 uuid = UUID(uuidString: "E621E1F8-C36C-495A-93FC-0C247A3E6E5F")!
let sut = try RootViewModel(
environment: .mock(uuid: { uuid }),
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.urlFieldText = "https://mastodon.social"
addIdentityViewModel.logInTapped()
let navigationViewModel = try wait(for: recorder.next(), timeout: 1)!
XCTAssertNotNil(navigationViewModel)
}
}