|
8 | 8 | #import <XCTest/XCTest.h> |
9 | 9 |
|
10 | 10 | #import <OCMock/OCMock.h> |
| 11 | +#import <React/RCTAssert.h> |
11 | 12 | #import <React/RCTBridgeModule.h> |
12 | 13 | #import <React/RCTBundleManager.h> |
13 | 14 | #import <React/RCTJavaScriptLoader.h> |
@@ -202,23 +203,34 @@ - (void)testInstantiatesRequestedModuleOnMainQueue |
202 | 203 | [instance invalidate]; |
203 | 204 | } |
204 | 205 |
|
205 | | -- (void)testInitializesDevSettingsBeforeLoadingBundle |
| 206 | +- (void)testInitializesDevSettingsAfterBundleLoadFailure |
206 | 207 | { |
207 | 208 | OCMStub([_mockDelegate unstableModulesRequiringMainQueueSetup]).andReturn(@[]); |
208 | 209 |
|
209 | 210 | XCTestExpectation *loadStarted = [self expectationWithDescription:@"bundle load started"]; |
210 | | - __block NSUInteger initializeCountAtBundleLoad = 0; |
| 211 | + __block RCTSourceLoadBlock loadComplete; |
211 | 212 | OCMStub([_mockDelegate loadBundleAtURL:[OCMArg any] onProgress:[OCMArg any] onComplete:[OCMArg any]]) |
212 | | - .andDo(^(NSInvocation *_) { |
213 | | - initializeCountAtBundleLoad = [FakeDevSettings.initCounts countForObject:FakeDevSettingsInitialize]; |
| 213 | + .andDo(^(NSInvocation *invocation) { |
| 214 | + __unsafe_unretained RCTSourceLoadBlock completion; |
| 215 | + [invocation getArgument:&completion atIndex:4]; |
| 216 | + loadComplete = [completion copy]; |
214 | 217 | [loadStarted fulfill]; |
215 | 218 | }); |
216 | 219 |
|
217 | 220 | RCTInstance *instance = [self makeInstance]; |
218 | 221 | [self waitForExpectations:@[ loadStarted ] timeout:5.0]; |
219 | | - [instance invalidate]; |
220 | 222 |
|
221 | | - XCTAssertEqual(initializeCountAtBundleLoad, 1u); |
| 223 | + XCTAssertEqual([FakeDevSettings.initCounts countForObject:FakeDevSettingsInitialize], 0u); |
| 224 | + |
| 225 | + RCTFatalHandler previousFatalHandler = RCTGetFatalHandler(); |
| 226 | + RCTSetFatalHandler(^(__unused NSError *error){ |
| 227 | + }); |
| 228 | + loadComplete([NSError errorWithDomain:@"RCTInstanceTests" code:1 userInfo:nil], nil); |
| 229 | + RCTSetFatalHandler(previousFatalHandler); |
| 230 | + |
| 231 | + XCTAssertEqual([FakeDevSettings.initCounts countForObject:FakeDevSettingsInitialize], 1u); |
| 232 | + |
| 233 | + [instance invalidate]; |
222 | 234 | } |
223 | 235 |
|
224 | 236 | - (void)testBundleLoadAwaitsMainQueueModuleSetup |
|
0 commit comments