react-native-navigation的迁移库

UIViewController+RNNOptionsTest.m 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #import <XCTest/XCTest.h>
  2. #import "UIViewController+RNNOptions.h"
  3. #import <OCMock/OCMock.h>
  4. #import "RNNBottomTabOptions.h"
  5. @interface UIViewController_RNNOptionsTest : XCTestCase
  6. @property(nonatomic, retain) id uut;
  7. @end
  8. @implementation UIViewController_RNNOptionsTest
  9. - (void)setUp {
  10. [super setUp];
  11. self.uut = [OCMockObject partialMockForObject:[UIViewController new]];
  12. }
  13. - (void)test_setTabBarItemBadge_shouldSetValidValue {
  14. [self.uut setTabBarItemBadge:@"badge"];
  15. XCTAssertEqual([self.uut tabBarItem].badgeValue, @"badge");
  16. }
  17. - (void)test_setTabBarItemBadge_shouldResetWhenValueIsEmptyString {
  18. [self.uut setTabBarItemBadge:@"badge"];
  19. [self.uut setTabBarItemBadge:@""];
  20. XCTAssertEqual([self.uut tabBarItem].badgeValue, nil);
  21. }
  22. - (void)test_setTabBarItemBadge_shouldResetWhenValueIsNullObject {
  23. [self.uut setTabBarItemBadge:@"badge"];
  24. [self.uut setTabBarItemBadge:(id) [NSNull new]];
  25. XCTAssertEqual([self.uut tabBarItem].badgeValue, nil);
  26. }
  27. //- (void)testSetDrawBehindTopBarTrue_shouldSetExtendedLayoutTrue {
  28. // [[self.uut expect] setExtendedLayoutIncludesOpaqueBars:YES];
  29. // [self.uut setDrawBehindTopBar:YES];
  30. // [self.uut verify];
  31. //}
  32. //
  33. //- (void)testSetDrawBehindTabBarTrue_shouldSetExtendedLayoutTrue {
  34. // [[self.uut expect] setExtendedLayoutIncludesOpaqueBars:YES];
  35. // [self.uut setDrawBehindTabBar:YES];
  36. // [self.uut verify];
  37. //}
  38. //
  39. //- (void)testSetDrawBehindTopBarFalse_shouldNotCallExtendedLayout {
  40. // [[self.uut reject] setExtendedLayoutIncludesOpaqueBars:NO];
  41. // [self.uut setDrawBehindTopBar:NO];
  42. // [self.uut verify];
  43. //}
  44. //
  45. //- (void)testSetDrawBehindTabBarFalse_shouldNotCallExtendedLayout {
  46. // [[self.uut reject] setExtendedLayoutIncludesOpaqueBars:NO];
  47. // [self.uut setDrawBehindTabBar:NO];
  48. // [self.uut verify];
  49. //}
  50. //
  51. //- (void)testSetDrawBehindTopBarFalse_shouldSetCorrectEdgesForExtendedLayout {
  52. // [self.uut setDrawBehindTopBar:NO];
  53. // UIRectEdge expectedRectEdge = UIRectEdgeLeft | UIRectEdgeBottom | UIRectEdgeRight;
  54. // XCTAssertEqual([self.uut edgesForExtendedLayout], expectedRectEdge);
  55. //}
  56. //
  57. //- (void)testSetDrawBehindTapBarFalse_shouldSetCorrectEdgesForExtendedLayout {
  58. // [self.uut setDrawBehindTabBar:NO];
  59. // UIRectEdge expectedRectEdge = UIRectEdgeTop | UIRectEdgeLeft | UIRectEdgeRight;
  60. // XCTAssertEqual([self.uut edgesForExtendedLayout], expectedRectEdge);
  61. //}
  62. - (void)testSetBackgroundImageShouldNotAddViewIfImageNil {
  63. NSUInteger subviewsCount = [[[self.uut view] subviews] count];
  64. [self.uut setBackgroundImage:nil];
  65. XCTAssertEqual([[[self.uut view] subviews] count], subviewsCount);
  66. }
  67. - (void)testSetBackgroundImageShouldAddUIImageViewSubview {
  68. NSUInteger subviewsCount = [[[self.uut view] subviews] count];
  69. [self.uut setBackgroundImage:[UIImage new]];
  70. XCTAssertEqual([[[self.uut view] subviews] count], subviewsCount + 1);
  71. }
  72. - (void)testSetBackgroundImageShouldAddUIImageViewSubviewWithImage {
  73. UIImage *image = [UIImage new];
  74. [self.uut setBackgroundImage:image];
  75. UIImageView *imageView = [[[self.uut view] subviews] firstObject];
  76. XCTAssertEqual(imageView.image, image);
  77. }
  78. @end