Skip to content

Commit

Permalink
Added unit test for isLinkingRelatedRequest function
Browse files Browse the repository at this point in the history
  • Loading branch information
NidhiDixit09 committed Jan 7, 2025
1 parent 94d6ab6 commit f992c00
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
43 changes: 43 additions & 0 deletions Branch-TestBed/Branch-SDK-Tests/BNCServerInterfaceTests.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// BNCServerInterfaceTests.m
// Branch-SDK-Tests
//
// Created by Nidhi Dixit on 1/7/25.
// Copyright © 2025 Branch, Inc. All rights reserved.
//

#import <XCTest/XCTest.h>
#import "Branch/BNCServerInterface.h"

@interface BNCServerInterface()
- (BOOL)isLinkingRelatedRequest:(NSString *)endpoint postParams:(NSDictionary *)post;
@end

@interface BNCServerInterfaceTests : XCTestCase
@end

@implementation BNCServerInterfaceTests

- (void)testIsLinkingRelatedRequest {

BNCServerInterface *serverInterface = [[BNCServerInterface alloc] init];

// install
XCTAssertTrue([serverInterface isLinkingRelatedRequest:@"/v1/install" postParams:nil]);

// open
XCTAssertFalse([serverInterface isLinkingRelatedRequest:@"/v1/open" postParams:nil]);
XCTAssertFalse([serverInterface isLinkingRelatedRequest:@"/v1/open" postParams:@{}]);
XCTAssertTrue([serverInterface isLinkingRelatedRequest:@"/v1/open" postParams:@{@"spotlight_identifier":@"io.branch.link.v1.url.testbed.app.link/1234"}]);
XCTAssertTrue([serverInterface isLinkingRelatedRequest:@"/v1/open" postParams:@{@"link_identifier": @"1305991233204308323"}]);
XCTAssertTrue([serverInterface isLinkingRelatedRequest:@"/v1/open" postParams:@{@"universal_link_url":@"branchtest://open?_branch_referrer=H4sIAAAAAAAAA8soKSkottLXT8pLLkktLklKTd"}]);
XCTAssertFalse([serverInterface isLinkingRelatedRequest:@"/v1/open" postParams:@{@"uri_scheme" : @"branchtest"}]);

// v2/event
XCTAssertFalse([serverInterface isLinkingRelatedRequest:@"/v2/event" postParams:@{@"spotlight_identifier":@"io.branch.link.v1.url.testbed.app.link/1234"}]);

// v1/url
XCTAssertTrue([serverInterface isLinkingRelatedRequest:@"/v1/url" postParams:nil]);

}
@end
4 changes: 4 additions & 0 deletions Branch-TestBed/Branch-TestBed.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@
C17DAF7B2AC20C2000B16B1A /* BranchClassTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C17DAF7A2AC20C2000B16B1A /* BranchClassTests.m */; };
C1CC888229BAAFC000BDD2B5 /* BNCReferringURLUtilityTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C1CC888129BAAFC000BDD2B5 /* BNCReferringURLUtilityTests.m */; };
E72489D228E40D0200DCD8FD /* PasteControlViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E72489D128E40D0200DCD8FD /* PasteControlViewController.m */; };
E74B54402D2DB0660049A89D /* BNCServerInterfaceTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E74B543F2D2DB0660049A89D /* BNCServerInterfaceTests.m */; };
E7A728BD2AA9A112009343B7 /* BNCAPIServerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = E7A728BC2AA9A112009343B7 /* BNCAPIServerTest.m */; };
F1CF14111F4CC79F00BB2694 /* CoreSpotlight.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 67F270881BA9FCFF002546A7 /* CoreSpotlight.framework */; settings = {ATTRIBUTES = (Required, ); }; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -538,6 +539,7 @@
C1CC888129BAAFC000BDD2B5 /* BNCReferringURLUtilityTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BNCReferringURLUtilityTests.m; sourceTree = "<group>"; };
E72489D028E40D0200DCD8FD /* PasteControlViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PasteControlViewController.h; sourceTree = "<group>"; };
E72489D128E40D0200DCD8FD /* PasteControlViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PasteControlViewController.m; sourceTree = "<group>"; };
E74B543F2D2DB0660049A89D /* BNCServerInterfaceTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BNCServerInterfaceTests.m; sourceTree = "<group>"; };
E7A728BC2AA9A112009343B7 /* BNCAPIServerTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BNCAPIServerTest.m; sourceTree = "<group>"; };
F1D4F9AC1F323F01002D13FF /* Branch-TestBed-UITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Branch-TestBed-UITests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -648,6 +650,7 @@
5F8650192B76DA3200364BDE /* NSMutableDictionaryBranchTests.m */,
4D16839E2098C901008819E3 /* NSStringBranchTests.m */,
5F6D86D82BB5E9650068B536 /* BNCClassSerializationTests.m */,
E74B543F2D2DB0660049A89D /* BNCServerInterfaceTests.m */,
);
path = "Branch-SDK-Tests";
sourceTree = "<group>";
Expand Down Expand Up @@ -1360,6 +1363,7 @@
files = (
4D1683B82098C902008819E3 /* BNCEncodingUtilsTests.m in Sources */,
5F909B5E23314CE900A774D2 /* BNCJSONUtilityTests.m in Sources */,
E74B54402D2DB0660049A89D /* BNCServerInterfaceTests.m in Sources */,
5F909B722332BEF600A774D2 /* BranchLastAttributedTouchDataTests.m in Sources */,
5FC20E732A93D85F00D9E1C8 /* BNCRequestFactoryTests.m in Sources */,
5FA9112F29BC662000F3D35C /* BNCNetworkInterfaceTests.m in Sources */,
Expand Down

0 comments on commit f992c00

Please sign in to comment.