|
|
@@ -4,8 +4,9 @@
|
|
4
|
4
|
#import "RNNNavigationOptions.h"
|
|
5
|
5
|
#import "RNNTestRootViewCreator.h"
|
|
6
|
6
|
#import "RNNRootViewController.h"
|
|
7
|
|
-#import "RNNNavigationStackManager.h"
|
|
8
|
7
|
#import "RNNNavigationController.h"
|
|
|
8
|
+#import "RNNErrorHandler.h"
|
|
|
9
|
+#import <OCMock/OCMock.h>
|
|
9
|
10
|
|
|
10
|
11
|
@interface MockUINavigationController : RNNNavigationController
|
|
11
|
12
|
@property (nonatomic, strong) NSArray* willReturnVCs;
|
|
|
@@ -26,11 +27,15 @@
|
|
26
|
27
|
@interface RNNCommandsHandlerTest : XCTestCase
|
|
27
|
28
|
|
|
28
|
29
|
@property (nonatomic, strong) RNNStore* store;
|
|
|
30
|
+@property (nonatomic, strong) id overlayStore;
|
|
29
|
31
|
@property (nonatomic, strong) RNNCommandsHandler* uut;
|
|
30
|
32
|
@property (nonatomic, strong) RNNRootViewController* vc1;
|
|
31
|
33
|
@property (nonatomic, strong) RNNRootViewController* vc2;
|
|
32
|
34
|
@property (nonatomic, strong) RNNRootViewController* vc3;
|
|
33
|
35
|
@property (nonatomic, strong) MockUINavigationController* nvc;
|
|
|
36
|
+@property (nonatomic, strong) id controllerFactory;
|
|
|
37
|
+@property (nonatomic, strong) id overlayManager;
|
|
|
38
|
+@property (nonatomic, strong) id eventEmmiter;
|
|
34
|
39
|
|
|
35
|
40
|
@end
|
|
36
|
41
|
|
|
|
@@ -40,7 +45,11 @@
|
|
40
|
45
|
[super setUp];
|
|
41
|
46
|
// [self.store setReadyToReceiveCommands:true];
|
|
42
|
47
|
self.store = [[RNNStore alloc] init];
|
|
43
|
|
- self.uut = [[RNNCommandsHandler alloc] initWithStore:self.store controllerFactory:[[RNNControllerFactory alloc] initWithRootViewCreator:nil store:self.store eventEmitter:nil andBridge:nil] eventEmitter:nil];
|
|
|
48
|
+ self.overlayStore = [OCMockObject partialMockForObject:[[RNNStore alloc] init]];
|
|
|
49
|
+ self.eventEmmiter = [OCMockObject partialMockForObject:[RNNEventEmitter new]];
|
|
|
50
|
+ self.overlayManager = [OCMockObject partialMockForObject:[RNNOverlayManager new]];
|
|
|
51
|
+ self.controllerFactory = [OCMockObject partialMockForObject:[[RNNControllerFactory alloc] initWithRootViewCreator:nil eventEmitter:self.eventEmmiter andBridge:nil]];
|
|
|
52
|
+ self.uut = [[RNNCommandsHandler alloc] initWithStore:self.store overlayStore:self.overlayStore controllerFactory:self.controllerFactory eventEmitter:self.eventEmmiter stackManager:[RNNNavigationStackManager new] modalManager:[RNNModalManager new] overlayManager:self.overlayManager];
|
|
44
|
53
|
self.vc1 = [RNNRootViewController new];
|
|
45
|
54
|
self.vc2 = [RNNRootViewController new];
|
|
46
|
55
|
self.vc3 = [RNNRootViewController new];
|
|
|
@@ -67,7 +76,7 @@
|
|
67
|
76
|
-(NSArray*) getPublicMethodNamesForObject:(NSObject*)obj{
|
|
68
|
77
|
NSMutableArray* skipMethods = [NSMutableArray new];
|
|
69
|
78
|
|
|
70
|
|
- [skipMethods addObject:@"initWithStore:controllerFactory:eventEmitter:"];
|
|
|
79
|
+ [skipMethods addObject:@"initWithStore:overlayStore:controllerFactory:eventEmitter:stackManager:modalManager:overlayManager:"];
|
|
71
|
80
|
[skipMethods addObject:@"assertReady"];
|
|
72
|
81
|
[skipMethods addObject:@"removePopedViewControllers:"];
|
|
73
|
82
|
[skipMethods addObject:@".cxx_destruct"];
|
|
|
@@ -184,4 +193,88 @@
|
|
184
|
193
|
[self waitForExpectationsWithTimeout:1 handler:nil];
|
|
185
|
194
|
}
|
|
186
|
195
|
|
|
|
196
|
+- (void)testShowOverlay_createLayout {
|
|
|
197
|
+ [self.store setReadyToReceiveCommands:true];
|
|
|
198
|
+ OCMStub([self.overlayManager showOverlay:[OCMArg any]]);
|
|
|
199
|
+ NSDictionary* layout = @{};
|
|
|
200
|
+
|
|
|
201
|
+ [[self.controllerFactory expect] createLayout:layout saveToStore:self.overlayStore];
|
|
|
202
|
+ [self.uut showOverlay:layout completion:^{}];
|
|
|
203
|
+ [self.controllerFactory verify];
|
|
|
204
|
+}
|
|
|
205
|
+
|
|
|
206
|
+- (void)testShowOverlay_saveToOverlayStore {
|
|
|
207
|
+ [self.store setReadyToReceiveCommands:true];
|
|
|
208
|
+ OCMStub([self.overlayManager showOverlay:[OCMArg any]]);
|
|
|
209
|
+ OCMStub([self.controllerFactory createLayout:[OCMArg any] saveToStore:[OCMArg any]]);
|
|
|
210
|
+
|
|
|
211
|
+ [[self.controllerFactory expect] createLayout:[OCMArg any] saveToStore:self.overlayStore];
|
|
|
212
|
+ [self.uut showOverlay:@{} completion:^{}];
|
|
|
213
|
+ [self.overlayManager verify];
|
|
|
214
|
+}
|
|
|
215
|
+
|
|
|
216
|
+- (void)testShowOverlay_withCreatedLayout {
|
|
|
217
|
+ [self.store setReadyToReceiveCommands:true];
|
|
|
218
|
+ UIViewController* layoutVC = [RNNRootViewController new];
|
|
|
219
|
+ OCMStub([self.controllerFactory createLayout:[OCMArg any] saveToStore:[OCMArg any]]).andReturn(layoutVC);
|
|
|
220
|
+
|
|
|
221
|
+ [[self.overlayManager expect] showOverlay:layoutVC];
|
|
|
222
|
+ [self.uut showOverlay:@{} completion:^{}];
|
|
|
223
|
+ [self.overlayManager verify];
|
|
|
224
|
+}
|
|
|
225
|
+
|
|
|
226
|
+- (void)testShowOverlay_invokeNavigationCommandEventWithLayout {
|
|
|
227
|
+ [self.store setReadyToReceiveCommands:true];
|
|
|
228
|
+ OCMStub([self.overlayManager showOverlay:[OCMArg any]]);
|
|
|
229
|
+ OCMStub([self.controllerFactory createLayout:[OCMArg any] saveToStore:[OCMArg any]]);
|
|
|
230
|
+
|
|
|
231
|
+ NSDictionary* layout = @{};
|
|
|
232
|
+
|
|
|
233
|
+ [[self.eventEmmiter expect] sendOnNavigationCommandCompletion:@"showOverlay" params:[OCMArg any]];
|
|
|
234
|
+ [self.uut showOverlay:layout completion:^{}];
|
|
|
235
|
+ [self.eventEmmiter verify];
|
|
|
236
|
+}
|
|
|
237
|
+
|
|
|
238
|
+- (void)testDismissOverlay_findComponentFromOverlayStore {
|
|
|
239
|
+ [self.store setReadyToReceiveCommands:true];
|
|
|
240
|
+ NSString* componentId = @"componentId";
|
|
|
241
|
+ [[self.overlayStore expect] findComponentForId:componentId];
|
|
|
242
|
+ [self.uut dismissOverlay:componentId completion:^{} rejection:^(NSString *code, NSString *message, NSError *error) {}];
|
|
|
243
|
+ [self.overlayStore verify];
|
|
|
244
|
+}
|
|
|
245
|
+
|
|
|
246
|
+- (void)testDismissOverlay_dismissReturnedViewController {
|
|
|
247
|
+ [self.store setReadyToReceiveCommands:true];
|
|
|
248
|
+ NSString* componentId = @"componentId";
|
|
|
249
|
+ UIViewController* returnedView = [UIViewController new];
|
|
|
250
|
+ OCMStub([self.overlayStore findComponentForId:componentId]).andReturn(returnedView);
|
|
|
251
|
+
|
|
|
252
|
+ [[self.overlayManager expect] dismissOverlay:returnedView];
|
|
|
253
|
+ [self.uut dismissOverlay:componentId completion:^{} rejection:^(NSString *code, NSString *message, NSError *error) {}];
|
|
|
254
|
+ [self.overlayManager verify];
|
|
|
255
|
+}
|
|
|
256
|
+
|
|
|
257
|
+- (void)testDismissOverlay_handleErrorIfNoOverlayExists {
|
|
|
258
|
+ [self.store setReadyToReceiveCommands:true];
|
|
|
259
|
+ NSString* componentId = @"componentId";
|
|
|
260
|
+ id errorHandlerMockClass = [OCMockObject mockForClass:[RNNErrorHandler class]];
|
|
|
261
|
+
|
|
|
262
|
+ [[errorHandlerMockClass expect] reject:[OCMArg any] withErrorCode:1010 errorDescription:[OCMArg any]];
|
|
|
263
|
+ [self.uut dismissOverlay:componentId completion:[OCMArg any] rejection:[OCMArg any]];
|
|
|
264
|
+ [errorHandlerMockClass verify];
|
|
|
265
|
+}
|
|
|
266
|
+
|
|
|
267
|
+- (void)testDismissOverlay_invokeNavigationCommandEvent {
|
|
|
268
|
+ [self.store setReadyToReceiveCommands:true];
|
|
|
269
|
+ NSString* componentId = @"componentId";
|
|
|
270
|
+ OCMStub([self.overlayStore findComponentForId:componentId]).andReturn([UIViewController new]);
|
|
|
271
|
+
|
|
|
272
|
+ [[self.eventEmmiter expect] sendOnNavigationCommandCompletion:@"dismissOverlay" params:[OCMArg any]];
|
|
|
273
|
+ [self.uut dismissOverlay:componentId completion:^{
|
|
|
274
|
+
|
|
|
275
|
+ } rejection:^(NSString *code, NSString *message, NSError *error) {}];
|
|
|
276
|
+
|
|
|
277
|
+ [self.eventEmmiter verify];
|
|
|
278
|
+}
|
|
|
279
|
+
|
|
187
|
280
|
@end
|