metatext-app-ios-iphone-ipad/Tests/View Models/RootViewModelTests.swift

32 lines
940 B
Swift
Raw Normal View History

2020-08-03 17:20:51 +02:00
// Copyright © 2020 Metabolist. All rights reserved.
import XCTest
import Combine
import CombineExpectations
@testable import Metatext
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 {
let sut = RootViewModel(environment: .fresh())
2020-08-07 03:41:59 +02:00
let recorder = sut.$identityID.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()
2020-08-07 03:41:59 +02:00
addIdentityViewModel.addedIdentityID
.sink(receiveValue: sut.newIdentitySelected(id:))
.store(in: &cancellables)
2020-08-03 17:20:51 +02:00
addIdentityViewModel.urlFieldText = "https://mastodon.social"
addIdentityViewModel.goTapped()
2020-08-07 03:41:59 +02:00
let identityID = try wait(for: recorder.next(), timeout: 1)!
2020-08-03 17:20:51 +02:00
2020-08-07 03:41:59 +02:00
XCTAssertNotNil(identityID)
XCTAssertNotNil(sut.mainNavigationViewModel(identityID: identityID))
2020-08-03 17:20:51 +02:00
}
}