forked from wix/react-native-navigation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRNNSideMenuPresenterTest.m
85 lines (66 loc) · 3.49 KB
/
RNNSideMenuPresenterTest.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#import <XCTest/XCTest.h>
#import <OCMock/OCMock.h>
#import "RNNSideMenuPresenter.h"
#import "RNNSideMenuController.h"
@interface RNNSideMenuPresenterTest : XCTestCase
@property (nonatomic, strong) RNNSideMenuPresenter *uut;
@property (nonatomic, strong) RNNNavigationOptions *options;
@property (nonatomic, strong) id bindedViewController;
@end
@implementation RNNSideMenuPresenterTest
- (void)setUp {
[super setUp];
self.uut = [[RNNSideMenuPresenter alloc] init];
self.bindedViewController = [OCMockObject partialMockForObject:[RNNSideMenuController new]];
[self.uut bindViewController:self.bindedViewController];
self.options = [[RNNNavigationOptions alloc] initEmptyOptions];
}
- (void)testApplyOptionsShouldSetDefaultValues {
[[self.bindedViewController expect] side:MMDrawerSideLeft enabled:YES];
[[self.bindedViewController expect] side:MMDrawerSideRight enabled:YES];
[[self.bindedViewController expect] setShouldStretchLeftDrawer:YES];
[[self.bindedViewController expect] setShouldStretchRightDrawer:YES];
[[self.bindedViewController expect] setAnimationVelocityLeft:840.0f];
[[self.bindedViewController expect] setAnimationVelocityRight:840.0f];
[[self.bindedViewController reject] side:MMDrawerSideLeft width:0];
[[self.bindedViewController reject] side:MMDrawerSideRight width:0];
[[self.bindedViewController expect] setAnimationType:nil];
[self.uut applyOptions:self.options];
[self.bindedViewController verify];
}
- (void)testApplyOptionsShouldSetInitialValues {
self.options.sideMenu.left.enabled = [[Bool alloc] initWithBOOL:NO];
self.options.sideMenu.right.enabled = [[Bool alloc] initWithBOOL:NO];
self.options.sideMenu.left.shouldStretchDrawer = [[Bool alloc] initWithBOOL:NO];
self.options.sideMenu.right.shouldStretchDrawer = [[Bool alloc] initWithBOOL:NO];
self.options.sideMenu.right.animationVelocity = [[Double alloc] initWithValue:@(100.0f)];
self.options.sideMenu.left.animationVelocity = [[Double alloc] initWithValue:@(100.0f)];
[[self.bindedViewController expect] side:MMDrawerSideLeft enabled:NO];
[[self.bindedViewController expect] side:MMDrawerSideRight enabled:NO];
[[self.bindedViewController expect] setShouldStretchLeftDrawer:NO];
[[self.bindedViewController expect] setShouldStretchRightDrawer:NO];
[[self.bindedViewController expect] setAnimationVelocityLeft:100.0f];
[[self.bindedViewController expect] setAnimationVelocityRight:100.0f];
[self.uut applyOptions:self.options];
[self.bindedViewController verify];
}
- (void)testApplyOptionsOnInitShouldSetWidthOptions {
self.options.sideMenu.right.width = [[Double alloc] initWithValue:@(100.0f)];
self.options.sideMenu.left.width = [[Double alloc] initWithValue:@(100.0f)];
[[self.bindedViewController expect] side:MMDrawerSideLeft width:100.0f];
[[self.bindedViewController expect] side:MMDrawerSideRight width:100.0f];
[self.uut applyOptionsOnInit:self.options];
[self.bindedViewController verify];
}
- (void)testApplyOptionsOnInitShouldSetDefaultDrawerGestureMode {
[[self.bindedViewController expect] setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll];
[self.uut applyOptionsOnInit:self.options];
[self.bindedViewController verify];
}
- (void)testApplyOptionsOnInitShouldSetBezelDrawerGestureMode {
self.options.sideMenu.openGestureMode = [[SideMenuOpenMode alloc] initWithValue:@(MMOpenDrawerGestureModeNone)];
[[self.bindedViewController expect] setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeNone];
[self.uut applyOptionsOnInit:self.options];
[self.bindedViewController verify];
}
@end