@@ -25,7 +25,8 @@ class AWSPinpointPushNotificationsPluginClientBehaviourTests: AWSPinpointPushNot
25
25
26
26
XCTAssertEqual ( mockPinpoint. currentEndpointProfileCount, 1 )
27
27
XCTAssertEqual ( mockPinpoint. updateEndpointCount, 1 )
28
- XCTAssertEqual ( mockPinpoint. mockedPinpointEndpointProfile. user. userId, " newUserId " )
28
+ let updatedEndpoint = try XCTUnwrap ( mockPinpoint. updatedPinpointEndpointProfile)
29
+ XCTAssertEqual ( updatedEndpoint. user. userId, " newUserId " )
29
30
}
30
31
31
32
func testIdentifyUser_withProfile_shouldUpdateUserProfile( ) async throws {
@@ -38,13 +39,14 @@ class AWSPinpointPushNotificationsPluginClientBehaviourTests: AWSPinpointPushNot
38
39
39
40
XCTAssertEqual ( mockPinpoint. currentEndpointProfileCount, 1 )
40
41
XCTAssertEqual ( mockPinpoint. updateEndpointCount, 1 )
41
- XCTAssertEqual ( mockPinpoint. mockedPinpointEndpointProfile. user. userId, " newUserId " )
42
- XCTAssertEqual ( mockPinpoint. mockedPinpointEndpointProfile. attributes. count, 3 )
43
- XCTAssertEqual ( mockPinpoint. mockedPinpointEndpointProfile. attributes [ " name " ] ? . first, " Name " )
44
- XCTAssertEqual ( mockPinpoint. mockedPinpointEndpointProfile. attributes [ " email " ] ? . first, " Email " )
45
- XCTAssertEqual ( mockPinpoint. mockedPinpointEndpointProfile. attributes [ " plan " ] ? . first, " Plan " )
46
- XCTAssertTrue ( mockPinpoint. mockedPinpointEndpointProfile. metrics. isEmpty)
47
- XCTAssertNil ( mockPinpoint. mockedPinpointEndpointProfile. user. userAttributes)
42
+ let updatedEndpoint = try XCTUnwrap ( mockPinpoint. updatedPinpointEndpointProfile)
43
+ XCTAssertEqual ( updatedEndpoint. user. userId, " newUserId " )
44
+ XCTAssertEqual ( updatedEndpoint. attributes. count, 3 )
45
+ XCTAssertEqual ( updatedEndpoint. attributes [ " name " ] ? . first, " Name " )
46
+ XCTAssertEqual ( updatedEndpoint. attributes [ " email " ] ? . first, " Email " )
47
+ XCTAssertEqual ( updatedEndpoint. attributes [ " plan " ] ? . first, " Plan " )
48
+ XCTAssertTrue ( updatedEndpoint. metrics. isEmpty)
49
+ XCTAssertNil ( updatedEndpoint. user. userAttributes)
48
50
}
49
51
50
52
func testIdentifyUser_withAnalyticsProfile_shouldUpdateUserProfile( ) async throws {
@@ -60,14 +62,15 @@ class AWSPinpointPushNotificationsPluginClientBehaviourTests: AWSPinpointPushNot
60
62
61
63
XCTAssertEqual ( mockPinpoint. currentEndpointProfileCount, 1 )
62
64
XCTAssertEqual ( mockPinpoint. updateEndpointCount, 1 )
63
- XCTAssertEqual ( mockPinpoint. mockedPinpointEndpointProfile. user. userId, " newUserId " )
64
- XCTAssertEqual ( mockPinpoint. mockedPinpointEndpointProfile. attributes. count, 2 )
65
- XCTAssertEqual ( mockPinpoint. mockedPinpointEndpointProfile. attributes [ " attribute " ] ? . first, " string " )
66
- XCTAssertEqual ( mockPinpoint. mockedPinpointEndpointProfile. attributes [ " boolAttribute " ] ? . first, " true " )
67
- XCTAssertEqual ( mockPinpoint. mockedPinpointEndpointProfile. metrics [ " metric " ] , 2.0 )
68
- XCTAssertEqual ( mockPinpoint. mockedPinpointEndpointProfile. metrics [ " intMetric " ] , 1 )
69
- XCTAssertEqual ( mockPinpoint. mockedPinpointEndpointProfile. metrics. count, 2 )
70
- XCTAssertNil ( mockPinpoint. mockedPinpointEndpointProfile. user. userAttributes)
65
+ let updatedEndpoint = try XCTUnwrap ( mockPinpoint. updatedPinpointEndpointProfile)
66
+ XCTAssertEqual ( updatedEndpoint. user. userId, " newUserId " )
67
+ XCTAssertEqual ( updatedEndpoint. attributes. count, 2 )
68
+ XCTAssertEqual ( updatedEndpoint. attributes [ " attribute " ] ? . first, " string " )
69
+ XCTAssertEqual ( updatedEndpoint. attributes [ " boolAttribute " ] ? . first, " true " )
70
+ XCTAssertEqual ( updatedEndpoint. metrics [ " metric " ] , 2.0 )
71
+ XCTAssertEqual ( updatedEndpoint. metrics [ " intMetric " ] , 1 )
72
+ XCTAssertEqual ( updatedEndpoint. metrics. count, 2 )
73
+ XCTAssertNil ( updatedEndpoint. user. userAttributes)
71
74
}
72
75
73
76
func testIdentifyUser_withBasicProfile_shouldUpdateUserProfile( ) async throws {
@@ -83,14 +86,15 @@ class AWSPinpointPushNotificationsPluginClientBehaviourTests: AWSPinpointPushNot
83
86
84
87
XCTAssertEqual ( mockPinpoint. currentEndpointProfileCount, 1 )
85
88
XCTAssertEqual ( mockPinpoint. updateEndpointCount, 1 )
86
- XCTAssertEqual ( mockPinpoint. mockedPinpointEndpointProfile. user. userId, " newUserId " )
87
- XCTAssertEqual ( mockPinpoint. mockedPinpointEndpointProfile. attributes. count, 2 )
88
- XCTAssertEqual ( mockPinpoint. mockedPinpointEndpointProfile. attributes [ " attribute " ] ? . first, " string " )
89
- XCTAssertEqual ( mockPinpoint. mockedPinpointEndpointProfile. attributes [ " boolAttribute " ] ? . first, " true " )
90
- XCTAssertEqual ( mockPinpoint. mockedPinpointEndpointProfile. metrics [ " metric " ] , 2.0 )
91
- XCTAssertEqual ( mockPinpoint. mockedPinpointEndpointProfile. metrics [ " intMetric " ] , 1 )
92
- XCTAssertEqual ( mockPinpoint. mockedPinpointEndpointProfile. metrics. count, 2 )
93
- XCTAssertNil ( mockPinpoint. mockedPinpointEndpointProfile. user. userAttributes)
89
+ let updatedEndpoint = try XCTUnwrap ( mockPinpoint. updatedPinpointEndpointProfile)
90
+ XCTAssertEqual ( updatedEndpoint. user. userId, " newUserId " )
91
+ XCTAssertEqual ( updatedEndpoint. attributes. count, 2 )
92
+ XCTAssertEqual ( updatedEndpoint. attributes [ " attribute " ] ? . first, " string " )
93
+ XCTAssertEqual ( updatedEndpoint. attributes [ " boolAttribute " ] ? . first, " true " )
94
+ XCTAssertEqual ( updatedEndpoint. metrics [ " metric " ] , 2.0 )
95
+ XCTAssertEqual ( updatedEndpoint. metrics [ " intMetric " ] , 1 )
96
+ XCTAssertEqual ( updatedEndpoint. metrics. count, 2 )
97
+ XCTAssertNil ( updatedEndpoint. user. userAttributes)
94
98
}
95
99
96
100
func testIdentifyUser_withPinpointProfile_shouldUpdateUserProfile( ) async throws {
@@ -110,26 +114,29 @@ class AWSPinpointPushNotificationsPluginClientBehaviourTests: AWSPinpointPushNot
110
114
111
115
XCTAssertEqual ( mockPinpoint. currentEndpointProfileCount, 1 )
112
116
XCTAssertEqual ( mockPinpoint. updateEndpointCount, 1 )
113
- XCTAssertEqual ( mockPinpoint. mockedPinpointEndpointProfile. attributes [ " attribute " ] ? . first, " string " )
114
- XCTAssertEqual ( mockPinpoint. mockedPinpointEndpointProfile. attributes [ " attributes " ] ? . count, 2 )
115
- XCTAssertEqual ( mockPinpoint. mockedPinpointEndpointProfile. attributes [ " attributes " ] ? . first, " string " )
116
- XCTAssertEqual ( mockPinpoint. mockedPinpointEndpointProfile. attributes [ " boolAttribute " ] ? . first, " true " )
117
- XCTAssertEqual ( mockPinpoint. mockedPinpointEndpointProfile. metrics [ " metric " ] , 2 )
118
- XCTAssertEqual ( mockPinpoint. mockedPinpointEndpointProfile. metrics [ " intMetric " ] , 1 )
119
- XCTAssertEqual ( mockPinpoint. mockedPinpointEndpointProfile. user. userId, " newUserId " )
120
- XCTAssertEqual ( mockPinpoint. mockedPinpointEndpointProfile. user. userAttributes ? [ " roles " ] ? . count, 2 )
121
- XCTAssertEqual ( mockPinpoint. mockedPinpointEndpointProfile. user. userAttributes ? [ " roles " ] ? . first, " Test " )
117
+ let updatedEndpoint = try XCTUnwrap ( mockPinpoint. updatedPinpointEndpointProfile)
118
+ XCTAssertEqual ( updatedEndpoint. attributes [ " attribute " ] ? . first, " string " )
119
+ XCTAssertEqual ( updatedEndpoint. attributes [ " attributes " ] ? . count, 2 )
120
+ XCTAssertEqual ( updatedEndpoint. attributes [ " attributes " ] ? . first, " string " )
121
+ XCTAssertEqual ( updatedEndpoint. attributes [ " boolAttribute " ] ? . first, " true " )
122
+ XCTAssertEqual ( updatedEndpoint. metrics [ " metric " ] , 2 )
123
+ XCTAssertEqual ( updatedEndpoint. metrics [ " intMetric " ] , 1 )
124
+ XCTAssertEqual ( updatedEndpoint. user. userId, " newUserId " )
125
+ XCTAssertEqual ( updatedEndpoint. user. userAttributes ? [ " roles " ] ? . count, 2 )
126
+ XCTAssertEqual ( updatedEndpoint. user. userAttributes ? [ " roles " ] ? . first, " Test " )
122
127
}
123
128
124
129
func testIdentifyUser_withPinpointProfileOptedOutOfMessages_shouldUpdateUserProfileOptOutValue( ) async throws {
125
130
try await plugin. identifyUser ( userId: " newUserId " , userProfile: nil )
126
- let updatedEndpoint = try XCTUnwrap ( mockPinpoint. updatedPinpointEndpointProfile)
131
+ var updatedEndpoint = try XCTUnwrap ( mockPinpoint. updatedPinpointEndpointProfile)
127
132
XCTAssertFalse ( updatedEndpoint. isOptOut)
128
133
129
134
try await plugin. identifyUser ( userId: " newUserId " , userProfile: PinpointUserProfile ( optedOutOfMessages: true ) )
135
+ updatedEndpoint = try XCTUnwrap ( mockPinpoint. updatedPinpointEndpointProfile)
130
136
XCTAssertTrue ( updatedEndpoint. isOptOut)
131
137
132
138
try await plugin. identifyUser ( userId: " newUserId " , userProfile: PinpointUserProfile ( name: " User " ) )
139
+ updatedEndpoint = try XCTUnwrap ( mockPinpoint. updatedPinpointEndpointProfile)
133
140
XCTAssertTrue ( updatedEndpoint. isOptOut)
134
141
}
135
142
@@ -140,7 +147,8 @@ class AWSPinpointPushNotificationsPluginClientBehaviourTests: AWSPinpointPushNot
140
147
141
148
XCTAssertEqual ( mockPinpoint. currentEndpointProfileCount, 1 )
142
149
XCTAssertEqual ( mockPinpoint. updateEndpointCount, 1 )
143
- XCTAssertEqual ( mockPinpoint. mockedPinpointEndpointProfile. deviceToken, apnsToken. asHexString ( ) )
150
+ let updatedEndpoint = try XCTUnwrap ( mockPinpoint. updatedPinpointEndpointProfile)
151
+ XCTAssertEqual ( updatedEndpoint. deviceToken, apnsToken. asHexString ( ) )
144
152
}
145
153
146
154
// MARK: - Record Notification received tests
0 commit comments