|
11 | 11 | #import "BNCSystemObserver.h" |
12 | 12 | #import "BNCConfig.h" |
13 | 13 | #import "BranchConstants.h" |
| 14 | +#import "Branch.h" |
14 | 15 |
|
15 | 16 | @interface BNCAPIServerTest : XCTestCase |
16 | 17 |
|
@@ -370,4 +371,42 @@ - (void)testValidationServiceURL_EUTracking { |
370 | 371 | XCTAssertTrue([url hasPrefix:expectedUrlPrefix]); |
371 | 372 | } |
372 | 373 |
|
| 374 | +- (void)testDefaultAPIURL { |
| 375 | + BNCServerAPI *serverAPI = [BNCServerAPI new]; |
| 376 | + XCTAssertNil(serverAPI.customAPIURL); |
| 377 | + |
| 378 | + NSString *storedUrl = [[BNCServerAPI sharedInstance] installServiceURL]; |
| 379 | + NSString *expectedUrl = [BNC_API_URL stringByAppendingString: @"/v1/install"]; |
| 380 | + XCTAssertEqualObjects(storedUrl, expectedUrl); |
| 381 | +} |
| 382 | + |
| 383 | +- (void)testSetAPIURL_Example { |
| 384 | + NSString *url = @"https://www.example.com"; |
| 385 | + [Branch setAPIUrl:url]; |
| 386 | + |
| 387 | + NSString *storedUrl = [[BNCServerAPI sharedInstance] installServiceURL]; |
| 388 | + NSString *expectedUrl = [url stringByAppendingString: @"/v1/install"]; |
| 389 | + XCTAssertEqualObjects(storedUrl, expectedUrl); |
| 390 | + |
| 391 | + [Branch setAPIUrl:BNC_API_URL]; |
| 392 | +} |
| 393 | + |
| 394 | +- (void)testSetAPIURL_InvalidHttp { |
| 395 | + NSString *url = @"Invalid://www.example.com"; |
| 396 | + [Branch setAPIUrl:url]; |
| 397 | + |
| 398 | + NSString *storedUrl = [[BNCServerAPI sharedInstance] installServiceURL]; |
| 399 | + NSString *expectedUrl = [BNC_API_URL stringByAppendingString: @"/v1/install"]; |
| 400 | + XCTAssertEqualObjects(storedUrl, expectedUrl); |
| 401 | +} |
| 402 | + |
| 403 | +- (void)testSetAPIURL_InvalidEmpty { |
| 404 | + NSString *url = @""; |
| 405 | + [Branch setAPIUrl:url]; |
| 406 | + |
| 407 | + NSString *storedUrl = [[BNCServerAPI sharedInstance] installServiceURL]; |
| 408 | + NSString *expectedUrl = [BNC_API_URL stringByAppendingString: @"/v1/install"]; |
| 409 | + XCTAssertEqualObjects(storedUrl, expectedUrl); |
| 410 | +} |
| 411 | + |
373 | 412 | @end |
0 commit comments