react-native-navigation的迁移库

RNNSideMenuControllerTest.m 3.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #import <XCTest/XCTest.h>
  2. #import "RNNSideMenuController.h"
  3. #import "RNNComponentViewController.h"
  4. #import "RNNTestRootViewCreator.h"
  5. @interface RNNSideMenuControllerTest : XCTestCase
  6. @property (nonatomic, strong) RNNSideMenuController *uut;
  7. @property (nonatomic, strong) RNNTestRootViewCreator *creator;
  8. @property (nonatomic, strong) RNNSideMenuChildVC *centerVC;
  9. @property (nonatomic, strong) RNNSideMenuChildVC *leftVC;
  10. @property (nonatomic, strong) RNNSideMenuChildVC *rightVC;
  11. @end
  12. @implementation RNNSideMenuControllerTest
  13. - (void)setUp {
  14. [super setUp];
  15. _creator = [[RNNTestRootViewCreator alloc] init];
  16. _leftVC = [[RNNSideMenuChildVC alloc] initWithLayoutInfo:nil creator:nil options:nil defaultOptions:nil presenter:nil eventEmitter:nil childViewController:self.generateComponent type:RNNSideMenuChildTypeLeft];
  17. _rightVC = [[RNNSideMenuChildVC alloc] initWithLayoutInfo:nil creator:nil options:nil defaultOptions:nil presenter:nil eventEmitter:nil childViewController:self.generateComponent type:RNNSideMenuChildTypeRight];
  18. _centerVC =[[RNNSideMenuChildVC alloc] initWithLayoutInfo:nil creator:nil options:nil defaultOptions:nil presenter:nil eventEmitter:nil childViewController:self.generateComponent type:RNNSideMenuChildTypeCenter];
  19. self.uut = [[RNNSideMenuController alloc] initWithLayoutInfo:nil creator:nil childViewControllers:@[_leftVC, _centerVC, _rightVC] options:[[RNNNavigationOptions alloc] initEmptyOptions] defaultOptions:nil presenter:nil eventEmitter:nil];
  20. }
  21. - (RNNComponentViewController *)generateComponent {
  22. return [[RNNComponentViewController alloc] initWithLayoutInfo:nil rootViewCreator:_creator eventEmitter:nil presenter:[RNNComponentPresenter new] options:[[RNNNavigationOptions alloc] initWithDict:@{}] defaultOptions:nil];
  23. }
  24. - (void)testSetSideMenuWidthShouldUpdateLeftReactViewFrameWidth {
  25. [self.uut side:MMDrawerSideLeft width:100];
  26. XCTAssertEqual(self.uut.left.child.view.frame.size.width, 100.f);
  27. }
  28. - (void)testSetSideMenuWidthShouldUpdateRightReactViewFrameWidth {
  29. [self.uut side:MMDrawerSideRight width:150];
  30. XCTAssertEqual(self.uut.right.child.view.frame.size.width, 150.f);
  31. }
  32. - (void)testGetCurrentChild {
  33. XCTestExpectation *expectation = [self expectationWithDescription:@"Testing Async Method"];
  34. XCTAssertEqual(_uut.getCurrentChild, _centerVC);
  35. [_uut openDrawerSide:MMDrawerSideLeft animated:NO completion:(void (^)(BOOL)) ^{
  36. XCTAssertEqual(_uut.getCurrentChild, _leftVC);
  37. }];
  38. [_uut closeDrawerAnimated:NO completion:nil];
  39. [_uut openDrawerSide:MMDrawerSideRight animated:NO completion:(void (^)(BOOL)) ^{
  40. XCTAssertEqual(_uut.getCurrentChild, _rightVC);
  41. [expectation fulfill];
  42. }];
  43. [self waitForExpectationsWithTimeout:1 handler:nil];
  44. }
  45. - (void)testResolveOptions {
  46. XCTestExpectation *expectation = [self expectationWithDescription:@"Testing Async Method"];
  47. RNNNavigationOptions *options = [[RNNNavigationOptions alloc] initEmptyOptions];
  48. options.sideMenu.left.visible = [[Bool alloc] initWithBOOL:YES];
  49. [_centerVC overrideOptions:options];
  50. XCTAssertTrue(_uut.resolveOptions.sideMenu.left.visible);
  51. [_uut openDrawerSide:MMDrawerSideLeft animated:NO completion:^(BOOL finished) {
  52. XCTAssertTrue(_uut.resolveOptions.sideMenu.left.visible);
  53. [expectation fulfill];
  54. }];
  55. [self waitForExpectationsWithTimeout:1 handler:nil];
  56. }
  57. @end