Skip to content

Instantly share code, notes, and snippets.

@lizixroy
Created September 8, 2016 02:34
Show Gist options
  • Save lizixroy/4896c948dc8294c0bcc58fe069e439ec to your computer and use it in GitHub Desktop.
Save lizixroy/4896c948dc8294c0bcc58fe069e439ec to your computer and use it in GitHub Desktop.
Roy's pet
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