Skip to content

Commit 19692a0

Browse files
committed
Added tests and changed NULL to nil
1 parent 9a0722e commit 19692a0

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

Branch-TestBed/Branch-SDK-Tests/BNCAPIServerTest.m

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#import "BNCSystemObserver.h"
1212
#import "BNCConfig.h"
1313
#import "BranchConstants.h"
14+
#import "Branch.h"
1415

1516
@interface BNCAPIServerTest : XCTestCase
1617

@@ -370,4 +371,42 @@ - (void)testValidationServiceURL_EUTracking {
370371
XCTAssertTrue([url hasPrefix:expectedUrlPrefix]);
371372
}
372373

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+
373412
@end

BranchSDK/BNCServerAPI.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ - (instancetype)init {
3030
self.useTrackingDomain = NO;
3131
self.useEUServers = NO;
3232
self.automaticallyEnableTrackingDomain = YES;
33-
self.customAPIURL = NULL;
33+
self.customAPIURL = nil;
3434
}
3535
return self;
3636
}

0 commit comments

Comments
 (0)