Skip to content

Commit

Permalink
DK-1067 - Added test case BranchUserTrackingDisabled
Browse files Browse the repository at this point in the history
  • Loading branch information
nidhi18apr committed Oct 6, 2020
1 parent ccae395 commit 6f298d0
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Branch.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
035E033D252BD1A80015E37C /* BranchUserTrackingDisabled.m in Sources */ = {isa = PBXBuildFile; fileRef = 035E033C252BD1A80015E37C /* BranchUserTrackingDisabled.m */; };
2B073C1020C97F44005D16D2 /* BNCURLBlackList.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B073C0D20C97F44005D16D2 /* BNCURLBlackList.h */; };
2B073C1120C97F44005D16D2 /* BNCURLBlackList.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B073C0D20C97F44005D16D2 /* BNCURLBlackList.h */; };
2B0B035520CA50FF0008938F /* BNCURLBlackList.m in Sources */ = {isa = PBXBuildFile; fileRef = 2B073C0C20C97F43005D16D2 /* BNCURLBlackList.m */; };
Expand Down Expand Up @@ -221,6 +222,7 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
035E033C252BD1A80015E37C /* BranchUserTrackingDisabled.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BranchUserTrackingDisabled.m; sourceTree = "<group>"; };
2B073C0C20C97F43005D16D2 /* BNCURLBlackList.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BNCURLBlackList.m; sourceTree = "<group>"; };
2B073C0D20C97F44005D16D2 /* BNCURLBlackList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BNCURLBlackList.h; sourceTree = "<group>"; };
4D046E8A20C881470073262B /* BranchNetworkServiceProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BranchNetworkServiceProtocol.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -500,6 +502,7 @@
4D0B753D211209FA00A06D97 /* BranchTestHost-tvOS.xcconfig */,
4DF8189D20ADDCB500441881 /* BranchTests-Bridging-Header.h */,
4DF818A020ADDCB600441881 /* BranchUniversalObject.Test.m */,
035E033C252BD1A80015E37C /* BranchUserTrackingDisabled.m */,
4D54C08520A6560400C76496 /* Info.plist */,
4D046E9620C8B5B20073262B /* NSData+Branch.Test.m */,
4D99773520AA09B300A63EE1 /* NSString+Branch.Test.m */,
Expand Down Expand Up @@ -830,6 +833,7 @@
4D159DDE20B62DD5005A9850 /* BNCPersistence.Test.m in Sources */,
4D046E9A20C8CE740073262B /* BNCTestNetworkService.Test.m in Sources */,
4D159DE320B62DD5005A9850 /* BNCThreads.Test.m in Sources */,
035E033D252BD1A80015E37C /* BranchUserTrackingDisabled.m in Sources */,
4D046E9720C8B5B20073262B /* NSData+Branch.Test.m in Sources */,
4D159DE020B62DD5005A9850 /* BNCTestCase.m in Sources */,
4D159DEA20B62DD5005A9850 /* NSString+Branch.Test.m in Sources */,
Expand Down
57 changes: 57 additions & 0 deletions BranchTests/BranchUserTrackingDisabled.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//
/**
@file BranchUserTrackingDisabled.m
@package BranchTests
@brief Tests creation of short link when tracking is disabled.
@author Nidhi Dixit
@date 2020
@copyright Copyright © 2020 Branch. All rights reserved.
*/

#import <XCTest/XCTest.h>
#import "BNCTestCase.h"
#import "BranchError.h"
#import "BNCLog.h"

@interface BranchUserTrackingDisabled : XCTestCase
@property (strong) Branch *branch;
@end

@implementation BranchUserTrackingDisabled

- (void)setUp {
if (!self.branch) {
self.branch = [[Branch alloc] init];
[self.branch startWithConfiguration:[[BranchConfiguration alloc] initWithKey:BNCTestBranchKey]];
self.branch.userTrackingDisabled = YES;
}
}

- (void)tearDown {
if (self.branch)
self.branch.userTrackingDisabled = NO;
}

- (void)testShortLink {

BranchUniversalObject *buo = [[BranchUniversalObject alloc] initWithCanonicalIdentifier:@"id-123"];
buo.title = @"Test link";
buo.canonicalUrl = @"https://branch.io/docs/unit-tests";
BranchLinkProperties *lp = [[BranchLinkProperties alloc] init];
lp.channel = @"UnitTests";
XCTestExpectation *expectation = [self expectationWithDescription:@"testShortLinks"];
[self.branch branchShortLinkWithContent:buo linkProperties:lp completion:
^ (NSURL * _Nullable shortURL, NSError * _Nullable error) {
XCTAssertNil(error);
XCTAssertNotNil(shortURL);
XCTAssertTrue([shortURL.absoluteString hasPrefix:@"https://testbed-mac.app.link/"]);
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:5.0 handler:nil];


}


@end
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
OTHER_CODE_SIGN_FLAGS = "--deep";
PRODUCT_BUNDLE_IDENTIFIER = "io.branch.sdk.TestBed-Mac";
PRODUCT_NAME = "$(TARGET_NAME)";
};
Expand All @@ -506,6 +507,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
OTHER_CODE_SIGN_FLAGS = "--deep";
PRODUCT_BUNDLE_IDENTIFIER = "io.branch.sdk.TestBed-Mac";
PRODUCT_NAME = "$(TARGET_NAME)";
};
Expand Down

0 comments on commit 6f298d0

Please sign in to comment.