forked from wix/react-native-navigation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRNNBasePresenterTest.m
63 lines (52 loc) · 2.29 KB
/
RNNBasePresenterTest.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#import <XCTest/XCTest.h>
#import "RNNBasePresenter.h"
#import <OCMock/OCMock.h>
#import "UIViewController+RNNOptions.h"
#import "RNNRootViewController.h"
@interface RNNBottomTabPresenterTest : XCTestCase
@property (nonatomic, strong) RNNBasePresenter *uut;
@property (nonatomic, strong) RNNNavigationOptions *options;
@property (nonatomic, strong) RNNRootViewController* bindedViewController;
@property (nonatomic, strong) id mockBindedViewController;
@end
@implementation RNNBottomTabPresenterTest
- (void)setUp {
[super setUp];
self.uut = [[RNNBasePresenter alloc] init];
self.bindedViewController = [RNNRootViewController 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_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];
}
- (void)testApplyOptions_setTabBarItemBadgeShouldWhenNoValue {
[self.uut bindViewController:self.mockBindedViewController];
self.options.bottomTab.badge = nil;
[[self.mockBindedViewController reject] rnn_setTabBarItemBadge:[OCMArg any]];
[self.uut applyOptions:self.options];
[self.mockBindedViewController verify];
}
@end