Created
March 16, 2015 08:05
-
-
Save odrobnik/2a2a7360c7ef1796a96a to your computer and use it in GitHub Desktop.
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
- (void)testLoginButtonTapped | |
{ | |
// mock a Server | |
id serverMock = OCMClassMock([Server class]); | |
OCMStub([serverMock loginUserWithName:[OCMArg any] password:[OCMArg any]]).andReturn(YES); | |
_loginVC.serverToUse = serverMock; | |
// simulate input in name field | |
_loginVC.userTextField.text = @"foo"; | |
[_loginVC.userTextField sendActionsForControlEvents:UIControlEventEditingChanged]; | |
// simulate input in password field | |
_loginVC.passwordTextField.text = @"bar"; | |
[_loginVC.passwordTextField sendActionsForControlEvents:UIControlEventEditingChanged]; | |
// simulate login button press | |
[_loginVC.loginButton sendActionsForControlEvents:UIControlEventTouchUpInside]; | |
// verify it has called the expected method | |
OCMVerify([serverMock loginUserWithName:[OCMArg checkWithBlock:^BOOL(NSString *obj) { | |
return [obj isEqualToString:@"foo"]; | |
}] password:[OCMArg any]]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
see https://gist.github.com/Cocoanetics/b2d80c4816d0de1cd207