#import #import "RNNBottomTabPresenter.h" #import #import "UIViewController+RNNOptions.h" @interface RNNBottomTabPresenterTest : XCTestCase @property (nonatomic, strong) RNNBottomTabPresenter *uut; @property (nonatomic, strong) RNNNavigationOptions *options; @property (nonatomic, strong) UIViewController* bindedViewController; @property (nonatomic, strong) id mockBindedViewController; @end @implementation RNNBottomTabPresenterTest - (void)setUp { [super setUp]; self.uut = [[RNNBottomTabPresenter alloc] init]; self.bindedViewController = [UIViewController new]; self.mockBindedViewController = [OCMockObject partialMockForObject:self.bindedViewController]; [self.uut bindViewController:self.mockBindedViewController]; self.options = [[RNNNavigationOptions alloc] initEmptyOptions]; } - (void)tearDown { [super tearDown]; [self.mockBindedViewController stopMocking]; self.bindedViewController = nil; } - (void)testApplyOptions_shouldSetTabBarItemBadgeWithDefaultWhenParentIsUITabBarController { OCMStub([self.mockBindedViewController parentViewController]).andReturn([UITabBarController new]); [[self.mockBindedViewController expect] rnn_setTabBarItemBadge:nil]; [self.uut applyOptions:self.options]; [self.mockBindedViewController verify]; } - (void)testApplyOptions_shouldSetTabBarItemBadgeOnlyWhenParentIsUITabBarController { [[self.mockBindedViewController reject] rnn_setTabBarItemBadge:[OCMArg any]]; [self.uut applyOptions:self.options]; [self.mockBindedViewController verify]; } - (void)testApplyOptions_shouldSetTabBarItemBadgeWithValue { OCMStub([self.mockBindedViewController parentViewController]).andReturn([UITabBarController new]); self.options.bottomTab.badge = [[Text alloc] initWithValue:@"badge"]; [[self.mockBindedViewController expect] rnn_setTabBarItemBadge:@"badge"]; [self.uut applyOptions:self.options]; [self.mockBindedViewController verify]; } - (void)testApplyOptions_setTabBarItemBadgeShouldNotCalledOnUITabBarController { [self.uut bindViewController:self.mockBindedViewController]; self.options.bottomTab.badge = [[Text alloc] initWithValue:@"badge"]; [[self.mockBindedViewController reject] rnn_setTabBarItemBadge:@"badge"]; [self.uut applyOptions:self.options]; [self.mockBindedViewController verify]; } @end