1#import <XCTest/XCTest.h> 2 3#import "EXAppLoader+Tests.h" 4#import "EXAppFetcherWithTimeout.h" 5#import "EXClientTestCase.h" 6#import "EXEnvironment.h" 7 8@interface EXAppFetcherWithTimeout (EXAppLoaderTests) 9 10@property (nonatomic, readonly) NSTimeInterval timeout; 11 12@end 13 14@interface EXAppLoaderConfigurationTests : EXClientTestCase 15 16@end 17 18@implementation EXAppLoaderConfigurationTests 19 20- (void)setUp 21{ 22 [super setUp]; 23 24 if ([EXEnvironment sharedEnvironment].testEnvironment == EXTestEnvironmentNone) { 25 [EXEnvironment sharedEnvironment].testEnvironment = EXTestEnvironmentLocal; 26 } 27} 28 29#pragma mark - app loader configuration in app.json 30 31- (void)testIsDefaultUpdatesConfigUsed 32{ 33 NSDictionary *manifest = @{}; 34 EXDevelopmentHomeLoader *appLoader = [[EXDevelopmentHomeLoader alloc] initWithManifestUrl:[NSURL URLWithString:@"exp://exp.host/@esamelson/test-fetch-update"]]; 35 [appLoader _fetchBundleWithManifest:manifest]; 36 XCTAssert([appLoader.appFetcher isKindOfClass:[EXAppFetcherWithTimeout class]], @"AppLoader should choose to use AppFetcherWithTimeout when fetching remotely"); 37 XCTAssert([(EXAppFetcherWithTimeout *)appLoader.appFetcher timeout] == kEXAppLoaderDefaultTimeout, @"AppFetcherWithTimeout should have the correct user-specified timeout length"); 38} 39 40- (void)testIsUpdateTimeoutConfigRespected 41{ 42 NSDictionary *manifest = @{ 43 @"updates": @{ 44 @"fallbackToCacheTimeout": @1000, 45 } 46 }; 47 EXDevelopmentHomeLoader *appLoader = [[EXDevelopmentHomeLoader alloc] initWithManifestUrl:[NSURL URLWithString:@"exp://exp.host/@esamelson/test-fetch-update"]]; 48 [appLoader _fetchBundleWithManifest:manifest]; 49 XCTAssert([appLoader.appFetcher isKindOfClass:[EXAppFetcherWithTimeout class]], @"AppLoader should choose to use AppFetcherWithTimeout when fetching remotely"); 50 XCTAssert([(EXAppFetcherWithTimeout *)appLoader.appFetcher timeout] == 1.0f, @"AppFetcherWithTimeout should have the correct user-specified timeout length"); 51} 52 53- (void)testIsOnErrorRecoveryIgnoredInExpoClient 54{ 55 NSDictionary *manifest = @{ 56 @"updates": @{ 57 @"checkAutomatically": @"ON_ERROR_RECOVERY" 58 } 59 }; 60 EXDevelopmentHomeLoader *appLoader = [[EXDevelopmentHomeLoader alloc] initWithManifestUrl:[NSURL URLWithString:@"exp://exp.host/@esamelson/test-fetch-update"]]; 61 [appLoader _fetchBundleWithManifest:manifest]; 62 XCTAssert([appLoader.appFetcher isKindOfClass:[EXAppFetcherWithTimeout class]], @"AppLoader should ignore ON_ERROR_RECOVERY in Expo Go"); 63} 64 65@end 66