react-native-navigation的迁移库

RNNSideMenuPresenterTest.m 3.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #import <XCTest/XCTest.h>
  2. #import <OCMock/OCMock.h>
  3. #import "RNNSideMenuPresenter.h"
  4. #import "RNNSideMenuController.h"
  5. @interface RNNSideMenuPresenterTest : XCTestCase
  6. @property (nonatomic, strong) RNNSideMenuPresenter *uut;
  7. @property (nonatomic, strong) RNNNavigationOptions *options;
  8. @property (nonatomic, strong) id bindedViewController;
  9. @end
  10. @implementation RNNSideMenuPresenterTest
  11. - (void)setUp {
  12. [super setUp];
  13. self.uut = [[RNNSideMenuPresenter alloc] init];
  14. self.bindedViewController = [OCMockObject partialMockForObject:[RNNSideMenuController new]];
  15. [self.uut boundViewController:self.bindedViewController];
  16. self.options = [[RNNNavigationOptions alloc] initEmptyOptions];
  17. }
  18. - (void)testApplyOptionsShouldSetDefaultValues {
  19. [[self.bindedViewController expect] side:MMDrawerSideLeft enabled:YES];
  20. [[self.bindedViewController expect] side:MMDrawerSideRight enabled:YES];
  21. [[self.bindedViewController expect] setShouldStretchLeftDrawer:YES];
  22. [[self.bindedViewController expect] setShouldStretchRightDrawer:YES];
  23. [[self.bindedViewController expect] setAnimationVelocityLeft:840.0f];
  24. [[self.bindedViewController expect] setAnimationVelocityRight:840.0f];
  25. [[self.bindedViewController reject] side:MMDrawerSideLeft width:0];
  26. [[self.bindedViewController reject] side:MMDrawerSideRight width:0];
  27. [[self.bindedViewController expect] setAnimationType:nil];
  28. [self.uut applyOptions:self.options];
  29. [self.bindedViewController verify];
  30. }
  31. - (void)testApplyOptionsShouldSetInitialValues {
  32. self.options.sideMenu.left.enabled = [[Bool alloc] initWithBOOL:NO];
  33. self.options.sideMenu.right.enabled = [[Bool alloc] initWithBOOL:NO];
  34. self.options.sideMenu.left.shouldStretchDrawer = [[Bool alloc] initWithBOOL:NO];
  35. self.options.sideMenu.right.shouldStretchDrawer = [[Bool alloc] initWithBOOL:NO];
  36. self.options.sideMenu.right.animationVelocity = [[Double alloc] initWithValue:@(100.0f)];
  37. self.options.sideMenu.left.animationVelocity = [[Double alloc] initWithValue:@(100.0f)];
  38. [[self.bindedViewController expect] side:MMDrawerSideLeft enabled:NO];
  39. [[self.bindedViewController expect] side:MMDrawerSideRight enabled:NO];
  40. [[self.bindedViewController expect] setShouldStretchLeftDrawer:NO];
  41. [[self.bindedViewController expect] setShouldStretchRightDrawer:NO];
  42. [[self.bindedViewController expect] setAnimationVelocityLeft:100.0f];
  43. [[self.bindedViewController expect] setAnimationVelocityRight:100.0f];
  44. [self.uut applyOptions:self.options];
  45. [self.bindedViewController verify];
  46. }
  47. - (void)testApplyOptionsOnInitShouldSetWidthOptions {
  48. self.options.sideMenu.right.width = [[Double alloc] initWithValue:@(100.0f)];
  49. self.options.sideMenu.left.width = [[Double alloc] initWithValue:@(100.0f)];
  50. [[self.bindedViewController expect] side:MMDrawerSideLeft width:100.0f];
  51. [[self.bindedViewController expect] side:MMDrawerSideRight width:100.0f];
  52. [self.uut applyOptionsOnInit:self.options];
  53. [self.bindedViewController verify];
  54. }
  55. - (void)testApplyOptionsOnInitShouldSetDefaultDrawerGestureMode {
  56. [[self.bindedViewController expect] setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll];
  57. [self.uut applyOptionsOnInit:self.options];
  58. [self.bindedViewController verify];
  59. }
  60. - (void)testApplyOptionsOnInitShouldSetBezelDrawerGestureMode {
  61. self.options.sideMenu.openGestureMode = [[SideMenuOpenMode alloc] initWithValue:@(MMOpenDrawerGestureModeNone)];
  62. [[self.bindedViewController expect] setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeNone];
  63. [self.uut applyOptionsOnInit:self.options];
  64. [self.bindedViewController verify];
  65. }
  66. @end