Skip to content

Commit 3b2b27b

Browse files
committed
CORE-1768 add opt in and opt out events to standard list
1 parent 6a20a55 commit 3b2b27b

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

Branch-SDK/BranchEvent.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ - (NSDictionary*) dictionary {
228228
BranchStandardEventStartTrial,
229229
BranchStandardEventClickAd,
230230
BranchStandardEventViewAd,
231+
BranchStandardEventOptOut,
232+
BranchStandardEventOptIn,
231233
];
232234
}
233235

Branch-TestBed/Branch-SDK-Tests/BranchEvent.Test.m

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,50 @@ - (void)testCustomViewAdEvent {
641641
XCTAssert([request.serverURL.absoluteString containsString:@"branch.io/v2/event/standard"]);
642642
}
643643

644+
- (void)testStandardOptInEvent {
645+
BranchEvent *event = [BranchEvent standardEvent:BranchStandardEventOptIn];
646+
647+
NSDictionary *eventDictionary = [event buildEventDictionary];
648+
XCTAssertNotNil(eventDictionary);
649+
XCTAssert([eventDictionary[@"name"] isEqualToString:@"OPT_IN"]);
650+
651+
BranchEventRequest *request = [event buildRequestWithEventDictionary:eventDictionary];
652+
XCTAssert([request.serverURL.absoluteString containsString:@"branch.io/v2/event/standard"]);
653+
}
654+
655+
- (void)testCustomOptInEvent {
656+
BranchEvent *event = [BranchEvent customEventWithName:@"OPT_IN"];
657+
658+
NSDictionary *eventDictionary = [event buildEventDictionary];
659+
XCTAssertNotNil(eventDictionary);
660+
XCTAssert([eventDictionary[@"name"] isEqualToString:@"OPT_IN"]);
661+
662+
BranchEventRequest *request = [event buildRequestWithEventDictionary:eventDictionary];
663+
XCTAssert([request.serverURL.absoluteString containsString:@"branch.io/v2/event/standard"]);
664+
}
665+
666+
- (void)testStandardOptOutEvent {
667+
BranchEvent *event = [BranchEvent standardEvent:BranchStandardEventOptOut];
668+
669+
NSDictionary *eventDictionary = [event buildEventDictionary];
670+
XCTAssertNotNil(eventDictionary);
671+
XCTAssert([eventDictionary[@"name"] isEqualToString:@"OPT_OUT"]);
672+
673+
BranchEventRequest *request = [event buildRequestWithEventDictionary:eventDictionary];
674+
XCTAssert([request.serverURL.absoluteString containsString:@"branch.io/v2/event/standard"]);
675+
}
676+
677+
- (void)testCustomOptOutEvent {
678+
BranchEvent *event = [BranchEvent customEventWithName:@"OPT_OUT"];
679+
680+
NSDictionary *eventDictionary = [event buildEventDictionary];
681+
XCTAssertNotNil(eventDictionary);
682+
XCTAssert([eventDictionary[@"name"] isEqualToString:@"OPT_OUT"]);
683+
684+
BranchEventRequest *request = [event buildRequestWithEventDictionary:eventDictionary];
685+
XCTAssert([request.serverURL.absoluteString containsString:@"branch.io/v2/event/standard"]);
686+
}
687+
644688
- (void)testJsonStringForAdTypeNone {
645689
BranchEvent *event = [BranchEvent standardEvent:BranchStandardEventViewAd];
646690
XCTAssertNil([event jsonStringForAdType:BranchEventAdTypeNone]);

0 commit comments

Comments
 (0)