react-native-navigation的迁移库

RNNSideMenuPresenterTest.m 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 bindViewController: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. @end