Skip to content

Commit

Permalink
Added tests and changed NULL to nil
Browse files Browse the repository at this point in the history
  • Loading branch information
nsingh-branch committed Feb 15, 2024
1 parent 9a0722e commit 19692a0
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
39 changes: 39 additions & 0 deletions Branch-TestBed/Branch-SDK-Tests/BNCAPIServerTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#import "BNCSystemObserver.h"
#import "BNCConfig.h"
#import "BranchConstants.h"
#import "Branch.h"

@interface BNCAPIServerTest : XCTestCase

Expand Down Expand Up @@ -370,4 +371,42 @@ - (void)testValidationServiceURL_EUTracking {
XCTAssertTrue([url hasPrefix:expectedUrlPrefix]);
}

- (void)testDefaultAPIURL {
BNCServerAPI *serverAPI = [BNCServerAPI new];
XCTAssertNil(serverAPI.customAPIURL);

NSString *storedUrl = [[BNCServerAPI sharedInstance] installServiceURL];
NSString *expectedUrl = [BNC_API_URL stringByAppendingString: @"/v1/install"];
XCTAssertEqualObjects(storedUrl, expectedUrl);
}

- (void)testSetAPIURL_Example {
NSString *url = @"https://www.example.com";
[Branch setAPIUrl:url];

NSString *storedUrl = [[BNCServerAPI sharedInstance] installServiceURL];
NSString *expectedUrl = [url stringByAppendingString: @"/v1/install"];
XCTAssertEqualObjects(storedUrl, expectedUrl);

[Branch setAPIUrl:BNC_API_URL];
}

- (void)testSetAPIURL_InvalidHttp {
NSString *url = @"Invalid://www.example.com";
[Branch setAPIUrl:url];

NSString *storedUrl = [[BNCServerAPI sharedInstance] installServiceURL];
NSString *expectedUrl = [BNC_API_URL stringByAppendingString: @"/v1/install"];
XCTAssertEqualObjects(storedUrl, expectedUrl);
}

- (void)testSetAPIURL_InvalidEmpty {
NSString *url = @"";
[Branch setAPIUrl:url];

NSString *storedUrl = [[BNCServerAPI sharedInstance] installServiceURL];
NSString *expectedUrl = [BNC_API_URL stringByAppendingString: @"/v1/install"];
XCTAssertEqualObjects(storedUrl, expectedUrl);
}

@end
2 changes: 1 addition & 1 deletion BranchSDK/BNCServerAPI.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ - (instancetype)init {
self.useTrackingDomain = NO;
self.useEUServers = NO;
self.automaticallyEnableTrackingDomain = YES;
self.customAPIURL = NULL;
self.customAPIURL = nil;
}
return self;
}
Expand Down

0 comments on commit 19692a0

Please sign in to comment.