@@ -49,6 +49,8 @@ @interface Leanplum (Test)
4949+ (NSSet <NSString *> *)parseEnabledCountersFromResponse : (NSDictionary *)response ;
5050+ (NSSet <NSString *> *)parseEnabledFeatureFlagsFromResponse : (NSDictionary *)response ;
5151+ (void )triggerMessageDisplayed : (LPActionContext *)context ;
52+ + (LPMessageArchiveData *)messageArchiveDataFromContext : (LPActionContext *)context ;
53+ + (NSString *)messageBodyFromContext : (LPActionContext *)context ;
5254
5355+ (void )trackGeofence : (LPGeofenceEventType *)event withValue : (double )value andInfo : (NSString *)info andArgs : (NSDictionary *)args andParameters : (NSDictionary *)params ;
5456
@@ -1835,4 +1837,60 @@ -(void)test_triggerMessageDisplayedCallsCallback
18351837 XCTAssertTrue (blockCalled);
18361838}
18371839
1840+ /* *
1841+ * Test that method messageBodyFromContext gets the correct message body for string.
1842+ */
1843+ -(void )test_messageBodyFromContextGetsCorrectBodyForString
1844+ {
1845+ NSString *messageID = @" testMessageID" ;
1846+ NSString *messageBody = @" testMessageBody" ;
1847+ NSString *recipientUserID = @" recipientUserID" ;
1848+
1849+ LPActionContext *actionContext = [[LPActionContext alloc ] init ];
1850+ id actionContextMock = OCMPartialMock (actionContext);
1851+
1852+ OCMStub ([actionContextMock messageId ]).andReturn (messageID);
1853+ OCMStub ([actionContextMock args ]).andReturn (@{@" Message" :messageBody});
1854+
1855+ XCTAssertTrue ([[Leanplum messageBodyFromContext: actionContext] isEqualToString: messageBody]);
1856+ }
1857+
1858+ /* *
1859+ * Test that method messageBodyFromContext gets the correct message body for
1860+ * dictionary with key "Text".
1861+ */
1862+ -(void )test_messageBodyFromContextGetsCorrectBodyForDictionaryKeyText
1863+ {
1864+ NSString *messageID = @" testMessageID" ;
1865+ NSString *messageBody = @" testMessageBody" ;
1866+ NSString *recipientUserID = @" recipientUserID" ;
1867+
1868+ LPActionContext *actionContext = [[LPActionContext alloc ] init ];
1869+ id actionContextMock = OCMPartialMock (actionContext);
1870+
1871+ OCMStub ([actionContextMock messageId ]).andReturn (messageID);
1872+ OCMStub ([actionContextMock args ]).andReturn (@{@" Message" :@{@" Text" :messageBody}});
1873+
1874+ XCTAssertTrue ([[Leanplum messageBodyFromContext: actionContext] isEqualToString: messageBody]);
1875+ }
1876+
1877+ /* *
1878+ * Test that method messageBodyFromContext gets the correct message body for
1879+ * dictionary with key "Text Value".
1880+ */
1881+ -(void )test_messageBodyFromContextGetsCorrectBodyForDictionaryKeyTextValue
1882+ {
1883+ NSString *messageID = @" testMessageID" ;
1884+ NSString *messageBody = @" testMessageBody" ;
1885+ NSString *recipientUserID = @" recipientUserID" ;
1886+
1887+ LPActionContext *actionContext = [[LPActionContext alloc ] init ];
1888+ id actionContextMock = OCMPartialMock (actionContext);
1889+
1890+ OCMStub ([actionContextMock messageId ]).andReturn (messageID);
1891+ OCMStub ([actionContextMock args ]).andReturn (@{@" Message" :@{@" Text Value" :messageBody}});
1892+
1893+ XCTAssertTrue ([[Leanplum messageBodyFromContext: actionContext] isEqualToString: messageBody]);
1894+ }
1895+
18381896@end
0 commit comments