react-native-navigation的迁移库

RNNSideMenuControllerTest.m 2.9KB

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