1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- #import <XCTest/XCTest.h>
- #import "RNNSideMenuController.h"
- #import "RNNComponentViewController.h"
- #import "RNNTestRootViewCreator.h"
-
- @interface RNNSideMenuControllerTest : XCTestCase
- @property (nonatomic, strong) RNNSideMenuController *uut;
- @property (nonatomic, strong) RNNTestRootViewCreator *creator;
- @property (nonatomic, strong) RNNSideMenuChildVC *centerVC;
- @property (nonatomic, strong) RNNSideMenuChildVC *leftVC;
- @property (nonatomic, strong) RNNSideMenuChildVC *rightVC;
- @end
-
- @implementation RNNSideMenuControllerTest
-
- - (void)setUp {
- [super setUp];
- _creator = [[RNNTestRootViewCreator alloc] init];
- _leftVC = [[RNNSideMenuChildVC alloc] initWithLayoutInfo:nil creator:nil options:nil defaultOptions:nil presenter:nil eventEmitter:nil childViewController:self.generateComponent type:RNNSideMenuChildTypeLeft];
- _rightVC = [[RNNSideMenuChildVC alloc] initWithLayoutInfo:nil creator:nil options:nil defaultOptions:nil presenter:nil eventEmitter:nil childViewController:self.generateComponent type:RNNSideMenuChildTypeRight];
- _centerVC =[[RNNSideMenuChildVC alloc] initWithLayoutInfo:nil creator:nil options:nil defaultOptions:nil presenter:nil eventEmitter:nil childViewController:self.generateComponent type:RNNSideMenuChildTypeCenter];
- self.uut = [[RNNSideMenuController alloc] initWithLayoutInfo:nil creator:nil childViewControllers:@[_leftVC, _centerVC, _rightVC] options:[[RNNNavigationOptions alloc] initEmptyOptions] defaultOptions:nil presenter:nil eventEmitter:nil];
- }
-
- - (RNNComponentViewController *)generateComponent {
- return [[RNNComponentViewController alloc] initWithLayoutInfo:nil rootViewCreator:_creator eventEmitter:nil presenter:[RNNComponentPresenter new] options:[[RNNNavigationOptions alloc] initWithDict:@{}] defaultOptions:nil];
- }
-
- - (void)testSetSideMenuWidthShouldUpdateLeftReactViewFrameWidth {
- [self.uut side:MMDrawerSideLeft width:100];
- XCTAssertEqual(self.uut.left.child.view.frame.size.width, 100.f);
- }
-
- - (void)testSetSideMenuWidthShouldUpdateRightReactViewFrameWidth {
- [self.uut side:MMDrawerSideRight width:150];
- XCTAssertEqual(self.uut.right.child.view.frame.size.width, 150.f);
- }
-
- - (void)testGetCurrentChild {
- XCTestExpectation *expectation = [self expectationWithDescription:@"Testing Async Method"];
- XCTAssertEqual(_uut.getCurrentChild, _centerVC);
-
- [_uut openDrawerSide:MMDrawerSideLeft animated:NO completion:(void (^)(BOOL)) ^{
- XCTAssertEqual(_uut.getCurrentChild, _leftVC);
- }];
-
- [_uut closeDrawerAnimated:NO completion:nil];
- [_uut openDrawerSide:MMDrawerSideRight animated:NO completion:(void (^)(BOOL)) ^{
- XCTAssertEqual(_uut.getCurrentChild, _rightVC);
- [expectation fulfill];
- }];
-
- [self waitForExpectationsWithTimeout:1 handler:nil];
- }
-
- - (void)testResolveOptions {
- XCTestExpectation *expectation = [self expectationWithDescription:@"Testing Async Method"];
-
- RNNNavigationOptions *options = [[RNNNavigationOptions alloc] initEmptyOptions];
- options.sideMenu.left.visible = [[Bool alloc] initWithBOOL:YES];
- [_centerVC overrideOptions:options];
-
- XCTAssertTrue(_uut.resolveOptions.sideMenu.left.visible);
-
- [_uut openDrawerSide:MMDrawerSideLeft animated:NO completion:^(BOOL finished) {
- XCTAssertTrue(_uut.resolveOptions.sideMenu.left.visible);
- [expectation fulfill];
- }];
-
- [self waitForExpectationsWithTimeout:1 handler:nil];
- }
-
- @end
|