1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- #import <XCTest/XCTest.h>
- #import "RNNBottomTabPresenter.h"
- #import <OCMock/OCMock.h>
- #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
|