Created
June 20, 2016 17:34
-
-
Save JoelJWest/d9d4ff3bef8081153429776519ce1b92 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
| NSString *textLabel = [NSString new]; | |
| id mockHud = OCMClassMock([MBProgressHUD class]); | |
| OCMExpect([mockHud showHUDAddedTo:settingsViewController.view animated:YES]); | |
| OCMExpect([mockHud labelText]).andReturn(textLabel); | |
| OCMExpect([mockHud hide:YES]); | |
| TOCFuture *accountEditFuture = [settingsViewController updateAccount]; | |
| XCTAssertNotNil(accountEditFuture, @"Should have received a non-nil instance of %@", [TOCFuture class]); | |
| XCTAssertEqualObjects(textLabel, @"Loading", @""); | |
| __block BOOL callbackInvoked = NO; | |
| [accountEditFuture thenDo:^ (id value) { | |
| XCTAssertNil(value); | |
| callbackInvoked = YES; | |
| }]; | |
| [accountEditFuture catchDo:^ (id failure) { | |
| XCTFail(@"Failed unexpectedly: %@", failure); | |
| callbackInvoked = YES; | |
| }]; | |
| XCTAssertTrue(callbackInvoked, @"The callback should have been hit no matter what"); | |
| OCMVerifyAll(mockController); | |
| OCMVerifyAll(mockEditor); | |
| OCMVerifyAll(mockHud); | |
| [mockEditor stopMocking]; | |
| [mockHud stopMocking]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment