react-native-navigation的迁移库

UIViewController+RNNOptionsTest.m 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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)testSetDrawBehindTopBarFalse_shouldNotCallExtendedLayout {
  28. // [[self.uut reject] setExtendedLayoutIncludesOpaqueBars:NO];
  29. // [self.uut setDrawBehindTopBar:NO];
  30. // [self.uut verify];
  31. //}
  32. //
  33. //- (void)testSetDrawBehindTabBarFalse_shouldNotCallExtendedLayout {
  34. // [[self.uut reject] setExtendedLayoutIncludesOpaqueBars:NO];
  35. // [self.uut setDrawBehindTabBar:NO];
  36. // [self.uut verify];
  37. //}
  38. //
  39. //- (void)testSetDrawBehindTopBarFalse_shouldSetCorrectEdgesForExtendedLayout {
  40. // [self.uut setDrawBehindTopBar:NO];
  41. // UIRectEdge expectedRectEdge = UIRectEdgeLeft | UIRectEdgeBottom | UIRectEdgeRight;
  42. // XCTAssertEqual([self.uut edgesForExtendedLayout], expectedRectEdge);
  43. //}
  44. //
  45. //- (void)testSetDrawBehindTapBarFalse_shouldSetCorrectEdgesForExtendedLayout {
  46. // [self.uut setDrawBehindTabBar:NO];
  47. // UIRectEdge expectedRectEdge = UIRectEdgeTop | UIRectEdgeLeft | UIRectEdgeRight;
  48. // XCTAssertEqual([self.uut edgesForExtendedLayout], expectedRectEdge);
  49. //}
  50. - (void)testSetBackgroundImageShouldNotAddViewIfImageNil {
  51. NSUInteger subviewsCount = [[[self.uut view] subviews] count];
  52. [self.uut setBackgroundImage:nil];
  53. XCTAssertEqual([[[self.uut view] subviews] count], subviewsCount);
  54. }
  55. - (void)testSetBackgroundImageShouldAddUIImageViewSubview {
  56. NSUInteger subviewsCount = [[[self.uut view] subviews] count];
  57. [self.uut setBackgroundImage:[UIImage new]];
  58. XCTAssertEqual([[[self.uut view] subviews] count], subviewsCount + 1);
  59. }
  60. - (void)testSetBackgroundImageShouldAddUIImageViewSubviewWithImage {
  61. UIImage *image = [UIImage new];
  62. [self.uut setBackgroundImage:image];
  63. UIImageView *imageView = [[[self.uut view] subviews] firstObject];
  64. XCTAssertEqual(imageView.image, image);
  65. }
  66. @end