123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- #import <XCTest/XCTest.h>
- #import "RNNBasePresenter.h"
- #import <OCMock/OCMock.h>
- #import "UIViewController+RNNOptions.h"
- #import "RNNComponentViewController.h"
-
- @interface RNNBottomTabPresenterTest : XCTestCase
-
- @property(nonatomic, strong) RNNBasePresenter *uut;
- @property(nonatomic, strong) RNNNavigationOptions *options;
- @property(nonatomic, strong) RNNComponentViewController *boundViewController;
- @property(nonatomic, strong) id mockBoundViewController;
-
- @end
-
- @implementation RNNBottomTabPresenterTest
-
- - (void)setUp {
- [super setUp];
- self.uut = [[RNNBasePresenter alloc] init];
- self.boundViewController = [RNNComponentViewController new];
- self.mockBoundViewController = [OCMockObject partialMockForObject:self.boundViewController];
- [self.uut bindViewController:self.mockBoundViewController];
- self.options = [[RNNNavigationOptions alloc] initEmptyOptions];
- }
-
- - (void)tearDown {
- [super tearDown];
- [self.mockBoundViewController stopMocking];
- self.boundViewController = nil;
- }
-
- - (void)testApplyOptions_shouldSetTabBarItemBadgeOnlyWhenParentIsUITabBarController {
- [[self.mockBoundViewController reject] setTabBarItemBadge:[OCMArg any]];
- [self.uut applyOptions:self.options];
- [self.mockBoundViewController verify];
- }
-
- - (void)testApplyOptions_shouldSetTabBarItemBadgeWithValue {
- OCMStub([self.mockBoundViewController parentViewController]).andReturn([UITabBarController new]);
- self.options.bottomTab.badge = [[Text alloc] initWithValue:@"badge"];
- [[self.mockBoundViewController expect] setTabBarItemBadge:self.options.bottomTab.badge.get];
- [self.uut applyOptions:self.options];
- [self.mockBoundViewController verify];
- }
-
- - (void)testApplyOptions_setTabBarItemBadgeShouldNotCalledOnUITabBarController {
- [self.uut bindViewController:self.mockBoundViewController];
- self.options.bottomTab.badge = [[Text alloc] initWithValue:@"badge"];
- [[self.mockBoundViewController reject] setTabBarItemBadge:[[RNNBottomTabOptions alloc] initWithDict:@{@"badge": @"badge"}]];
- [self.uut applyOptions:self.options];
- [self.mockBoundViewController verify];
- }
-
- - (void)testApplyOptions_setTabBarItemBadgeShouldWhenNoValue {
- [self.uut bindViewController:self.mockBoundViewController];
- self.options.bottomTab.badge = nil;
- [[self.mockBoundViewController reject] setTabBarItemBadge:[OCMArg any]];
- [self.uut applyOptions:self.options];
- [self.mockBoundViewController verify];
- }
-
- - (void)testGetPreferredStatusBarStyle_returnLightIfLight {
- RNNNavigationOptions * lightOptions = [[RNNNavigationOptions alloc] initEmptyOptions];
- lightOptions.statusBar.style = [[Text alloc] initWithValue:@"light"];
-
- XCTAssertEqual([_uut getStatusBarStyle:lightOptions], UIStatusBarStyleLightContent);
- }
-
- - (void)testGetPreferredStatusBarStyle_returnDefaultIfDark {
- RNNNavigationOptions * darkOptions = [[RNNNavigationOptions alloc] initEmptyOptions];
- darkOptions.statusBar.style = [[Text alloc] initWithValue:@"dark"];
-
- XCTAssertEqual([_uut getStatusBarStyle:darkOptions], UIStatusBarStyleDefault);
- }
-
- - (void)testGetPreferredStatusBarStyle_returnDefaultIfNil {
- RNNNavigationOptions * options = [[RNNNavigationOptions alloc] initEmptyOptions];
-
- XCTAssertEqual([_uut getStatusBarStyle:options], UIStatusBarStyleDefault);
- }
-
- - (void)testGetPreferredStatusBarStyle_considersDefaultOptions {
- RNNNavigationOptions * options = [[RNNNavigationOptions alloc] initEmptyOptions];
- RNNNavigationOptions * lightOptions = [[RNNNavigationOptions alloc] initEmptyOptions];
- lightOptions.statusBar.style = [[Text alloc] initWithValue:@"light"];
- [_uut setDefaultOptions:lightOptions];
-
- XCTAssertEqual([_uut getStatusBarStyle:options], UIStatusBarStyleLightContent);
- }
-
- - (void)testApplyOptionsOnInit_setSwipeToDismiss {
- self.options.modal.swipeToDismiss = [[Bool alloc] initWithBOOL:NO];
- XCTAssertFalse(_boundViewController.modalInPresentation);
- [self.uut applyOptionsOnInit:self.options];
- XCTAssertTrue(_boundViewController.modalInPresentation);
- }
-
-
-
- @end
|