-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Type hinting MPIdentityApiRequest.identities (#270)
- Loading branch information
1 parent
87ce71c
commit f56879f
Showing
5 changed files
with
56 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,10 @@ @interface MPIdentityApiRequestTests : MPBaseTestCase | |
|
||
@end | ||
|
||
@interface MPIdentityApiRequest () | ||
@property (nonatomic) NSMutableDictionary<NSNumber*, NSObject*> *mutableIdentities; | ||
@end | ||
|
||
@implementation MPIdentityApiRequestTests | ||
|
||
- (void)testSetNilIdentity { | ||
|
@@ -24,7 +28,7 @@ - (void)testSetNullIdentity { | |
XCTAssertEqualObjects([NSNull null], [request.identities objectForKey:@(MPIdentityOther)]); | ||
} | ||
|
||
- (void)testsetIdentity { | ||
- (void)testSetIdentity { | ||
MPIdentityApiRequest *request = [[MPIdentityApiRequest alloc] init]; | ||
[request setIdentity:@"foo" identityType:MPIdentityOther]; | ||
XCTAssertEqualObjects(@"foo", [request.identities objectForKey:@(MPIdentityOther)]); | ||
|
@@ -49,4 +53,28 @@ - (void)testIdentitiesAreNotNull { | |
XCTAssertNotEqualObjects(request.customerId, [NSNull null]); | ||
} | ||
|
||
- (void)testSetEmail { | ||
MPIdentityApiRequest *request = [[MPIdentityApiRequest alloc] init]; | ||
XCTAssertNil(request.email); | ||
request.email = @"[email protected]"; | ||
XCTAssertEqualObjects(@"[email protected]", request.email); | ||
XCTAssertEqualObjects(@"[email protected]", request.mutableIdentities[@(MPIdentityEmail)]); | ||
|
||
request.email = nil; | ||
XCTAssertNil(request.email); | ||
XCTAssertEqualObjects(request.mutableIdentities[@(MPIdentityEmail)], [NSNull null]); | ||
} | ||
|
||
- (void)testSetCustomerId { | ||
MPIdentityApiRequest *request = [[MPIdentityApiRequest alloc] init]; | ||
XCTAssertNil(request.customerId); | ||
request.customerId = @"some id"; | ||
XCTAssertEqualObjects(@"some id", request.customerId); | ||
XCTAssertEqualObjects(@"some id", request.mutableIdentities[@(MPIdentityCustomerId)]); | ||
|
||
request.customerId = nil; | ||
XCTAssertNil(request.customerId); | ||
XCTAssertEqualObjects(request.mutableIdentities[@(MPIdentityCustomerId)], [NSNull null]); | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,4 +64,19 @@ class mParticle_Swift_SDKTests: XCTestCase { | |
XCTAssertNotNil(MPIdentityErrorResponseCode(rawValue: 500)) | ||
XCTAssertNotNil(MPIdentityErrorResponseCode(rawValue: 502)) | ||
} | ||
|
||
func testMPIdentityApiRequestIdentitiesInterop() { | ||
let request = MPIdentityApiRequest() | ||
request.setIdentity("test id", identityType: .customerId) | ||
request.setIdentity("[email protected]", identityType: .email) | ||
|
||
var identities = [NSNumber: NSObject]() | ||
identities[NSNumber(value: MPIdentity.customerId.rawValue)] = NSString(string: "test id") | ||
identities[NSNumber(value: MPIdentity.email.rawValue)] = NSString(string: "[email protected]") | ||
XCTAssertEqual(identities, request.identities); | ||
|
||
request.email = nil | ||
identities[NSNumber(value: MPIdentity.email.rawValue)] = NSNull() | ||
XCTAssertEqual(identities, request.identities); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters