react-native-navigation的迁移库

UINavigationController+RNNOptionsTest.m 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #import <XCTest/XCTest.h>
  2. #import "UINavigationController+RNNOptions.h"
  3. @interface UINavigationController_RNNOptionsTest : XCTestCase
  4. @end
  5. @implementation UINavigationController_RNNOptionsTest
  6. - (void)setUp {
  7. [super setUp];
  8. }
  9. - (void)testSetBackButtonIcon_withColor_shouldSetColor {
  10. UIViewController* viewController = [UIViewController new];
  11. UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:viewController];
  12. UIColor* color = [UIColor blackColor];
  13. [nav rnn_setBackButtonIcon:nil withColor:color title:nil];
  14. XCTAssertEqual(color, viewController.navigationItem.backBarButtonItem.tintColor);
  15. }
  16. - (void)testSetBackButtonIcon_withColor_shouldSetTitle {
  17. UIViewController* viewController = [UIViewController new];
  18. UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:viewController];
  19. NSString* title = @"Title";
  20. [nav rnn_setBackButtonIcon:nil withColor:nil title:title];
  21. XCTAssertEqual(title, viewController.navigationItem.backBarButtonItem.title);
  22. }
  23. - (void)testSetBackButtonIcon_withColor_shouldSetIcon {
  24. UIViewController* viewController = [UIViewController new];
  25. UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:viewController];
  26. UIImage* icon = [UIImage new];
  27. [nav rnn_setBackButtonIcon:icon withColor:nil title:nil];
  28. XCTAssertEqual(icon, viewController.navigationItem.backBarButtonItem.image);
  29. }
  30. - (void)testSetBackButtonIcon_shouldSetTitleOnPreviousViewControllerIfExists {
  31. UIViewController* viewController = [UIViewController new];
  32. UIViewController* viewController2 = [UIViewController new];
  33. UINavigationController* nav = [[UINavigationController alloc] init];
  34. [nav setViewControllers:@[viewController, viewController2]];
  35. NSString* title = @"Title";
  36. [nav rnn_setBackButtonIcon:nil withColor:nil title:title];
  37. XCTAssertEqual(title, viewController.navigationItem.backBarButtonItem.title);
  38. }
  39. @end