Skip to content

Commit 66bff0c

Browse files
author
Adam Schlesinger
committed
Added test for checking formatting of a PUT
1 parent 7938eef commit 66bff0c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

iOS_SDK/OneSignalSDK/UnitTests/RequestTests.m

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,4 +734,23 @@ - (void)testSendExternalWithAuthUserId {
734734
XCTAssertTrue(checkHttpBody(request.urlRequest.HTTPBody, @{@"app_id" : testAppId, @"external_user_id" : testExternalUserId, @"external_user_id_auth_hash" : testExternalUserIdHashToken}));
735735
}
736736

737+
- (void)testConstructPut {
738+
let oneSignalRequest = [OneSignalRequest new];
739+
oneSignalRequest.path = @"test";
740+
oneSignalRequest.method = PUT;
741+
oneSignalRequest.parameters = @{
742+
@"int": @(123),
743+
@"double": @(1.23),
744+
@"string_normal": @"thisisastring",
745+
@"string_slashes": @"this/string/has/slashes",
746+
@"string_escapedchars": @"this\nstring\\has\"escape\tchars",
747+
};
748+
749+
let urlRequest = [oneSignalRequest urlRequest];
750+
let urlRequestBodyString = [NSString stringWithUTF8String:[urlRequest.HTTPBody bytes]];
751+
let expectedBodyString = @"{\"double\":1.23,\"int\":123,\"string_normal\":\"thisisastring\",\"string_slashes\":\"this/string/has/slashes\",\"string_escapedchars\":\"this\\nstring\\\\has\\\"escape\\tchars\"}";
752+
753+
XCTAssertTrue([urlRequestBodyString isEqualToString:expectedBodyString]);
754+
}
755+
737756
@end

0 commit comments

Comments
 (0)