|
@@ -0,0 +1,53 @@
|
|
1
|
+#import <XCTest/XCTest.h>
|
|
2
|
+#import "UINavigationController+RNNOptions.h"
|
|
3
|
+
|
|
4
|
+@interface UINavigationController_RNNOptionsTest : XCTestCase
|
|
5
|
+
|
|
6
|
+@end
|
|
7
|
+
|
|
8
|
+@implementation UINavigationController_RNNOptionsTest
|
|
9
|
+
|
|
10
|
+- (void)setUp {
|
|
11
|
+ [super setUp];
|
|
12
|
+}
|
|
13
|
+
|
|
14
|
+- (void)testSetBackButtonIcon_withColor_shouldSetColor {
|
|
15
|
+ UIViewController* viewController = [UIViewController new];
|
|
16
|
+ UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:viewController];
|
|
17
|
+ UIColor* color = [UIColor blackColor];
|
|
18
|
+
|
|
19
|
+ [nav rnn_setBackButtonIcon:nil withColor:color title:nil];
|
|
20
|
+ XCTAssertEqual(color, viewController.navigationItem.backBarButtonItem.tintColor);
|
|
21
|
+}
|
|
22
|
+
|
|
23
|
+- (void)testSetBackButtonIcon_withColor_shouldSetTitle {
|
|
24
|
+ UIViewController* viewController = [UIViewController new];
|
|
25
|
+ UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:viewController];
|
|
26
|
+ NSString* title = @"Title";
|
|
27
|
+
|
|
28
|
+ [nav rnn_setBackButtonIcon:nil withColor:nil title:title];
|
|
29
|
+ XCTAssertEqual(title, viewController.navigationItem.backBarButtonItem.title);
|
|
30
|
+}
|
|
31
|
+
|
|
32
|
+- (void)testSetBackButtonIcon_withColor_shouldSetIcon {
|
|
33
|
+ UIViewController* viewController = [UIViewController new];
|
|
34
|
+ UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:viewController];
|
|
35
|
+ UIImage* icon = [UIImage new];
|
|
36
|
+
|
|
37
|
+ [nav rnn_setBackButtonIcon:icon withColor:nil title:nil];
|
|
38
|
+ XCTAssertEqual(icon, viewController.navigationItem.backBarButtonItem.image);
|
|
39
|
+}
|
|
40
|
+
|
|
41
|
+- (void)testSetBackButtonIcon_shouldSetTitleOnPreviousViewControllerIfExists {
|
|
42
|
+ UIViewController* viewController = [UIViewController new];
|
|
43
|
+ UIViewController* viewController2 = [UIViewController new];
|
|
44
|
+ UINavigationController* nav = [[UINavigationController alloc] init];
|
|
45
|
+ [nav setViewControllers:@[viewController, viewController2]];
|
|
46
|
+ NSString* title = @"Title";
|
|
47
|
+
|
|
48
|
+ [nav rnn_setBackButtonIcon:nil withColor:nil title:title];
|
|
49
|
+ XCTAssertEqual(title, viewController.navigationItem.backBarButtonItem.title);
|
|
50
|
+}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+@end
|