Created
September 8, 2016 02:31
-
-
Save lizixroy/6da94c0be0fb6f92b68cd916f7728e8b to your computer and use it in GitHub Desktop.
Roy's test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LogInViewModelTests: XCTestCase { | |
private let disposeBag = DisposeBag() | |
private let timeout = 1.0 | |
var mockCellViewModelFactory: LabelAndTextFieldCellViewModelFactoryProtocol! | |
var mockLogInService: MockLogInService! | |
var logInViewModel: LogInViewModel! | |
override func setUp() { | |
super.setUp() | |
mockCellViewModelFactory = MockLabelAndTextFieldCellViewModelFactory() | |
mockLogInService = MockLogInService() | |
logInViewModel = LogInViewModel(cellViewModelFactory: mockCellViewModelFactory, logInService: mockLogInService) | |
} | |
func testCreateCellViewModels() { | |
// TODO: add this tests before anything else | |
} | |
func testLogInWhenRequiredFieldsAreEmpty() { | |
let expectation = expectationWithDescription("Should get DisplayErrorMessage UIEvent when required fields are empty") | |
mockLogInService.logInError = LogInError.IncompleteInput | |
logInViewModel.UIEvents.subscribeNext { event in | |
switch event { | |
case .DisplayErrorMessage(NSLocalizedString("ERROR_MESSAGE_NEED_TO_FILL_REQUIRED_FIELDS", comment: "Need to fill all required fields")): | |
expectation.fulfill() | |
default: | |
XCTFail("should get .DisplayErrorMessage with correct associated message") | |
} | |
}.addDisposableTo(disposeBag) | |
logInViewModel.logIn() | |
waitForExpectationsWithTimeout(timeout, handler: nil) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment