Skip to content

Commit c59f18b

Browse files
authored
test(active_period): add active period actionmanager test (#140)
* add active period actionmanager test * update tests
1 parent 82da371 commit c59f18b

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

Example/Tests/Classes/ActionManagerTest.m

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,4 +278,50 @@ - (void)test_push_token
278278
[self waitForExpectationsWithTimeout:2 handler:nil];
279279
}
280280

281+
- (void)test_active_period_false
282+
{
283+
LPActionManager *manager = [LPActionManager sharedManager];
284+
LPContextualValues *contextualValues = [[LPContextualValues alloc] init];
285+
286+
NSDictionary *config = [self _configForActivePeriodMatch:NO];
287+
288+
LeanplumMessageMatchResult result = [manager shouldShowMessage:@""
289+
withConfig:config
290+
when:@"event"
291+
withEventName:@"ActivePeriodTest"
292+
contextualValues:contextualValues];
293+
XCTAssertFalse(result.matchedActivePeriod);
294+
}
295+
296+
- (void)test_active_period_true
297+
{
298+
LPActionManager *manager = [LPActionManager sharedManager];
299+
LPContextualValues *contextualValues = [[LPContextualValues alloc] init];
300+
301+
NSDictionary *config = [self _configForActivePeriodMatch:YES];
302+
303+
LeanplumMessageMatchResult result = [manager shouldShowMessage:@""
304+
withConfig:config
305+
when:@"event"
306+
withEventName:@"ActivePeriodTest"
307+
contextualValues:contextualValues];
308+
XCTAssertTrue(result.matchedActivePeriod);
309+
310+
}
311+
312+
#pragma mark Helpers
313+
314+
-(NSDictionary *)_configForActivePeriodMatch:(BOOL)activePeriod
315+
{
316+
NSDictionary *config = @{@"whenLimits":@{@"children":@[]},
317+
@"whenTriggers":@{@"children":@[@{@"noun":@"ActivePeriodTest",
318+
@"subject":@"event",
319+
}],
320+
@"verb":@"OR"
321+
},
322+
@"startTime": activePeriod ? @1524507600000 : @956557100000,
323+
@"endTime": activePeriod ? @7836202020000 : @956557200000
324+
};
325+
return config;
326+
}
281327
@end

0 commit comments

Comments
 (0)