@@ -7,7 +7,6 @@ import 'package:amplify_analytics_pinpoint_dart/src/impl/analytics_client/endpoi
7
7
import 'package:amplify_analytics_pinpoint_dart/src/sdk/pinpoint.dart' ;
8
8
import 'package:amplify_core/amplify_core.dart' ;
9
9
import 'package:mocktail/mocktail.dart' ;
10
-
11
10
import 'package:test/test.dart' ;
12
11
13
12
import 'common/mock_device_context_info.dart' ;
@@ -262,6 +261,66 @@ void main() {
262
261
expect (endpoint.user! .userAttributes, isNull);
263
262
});
264
263
264
+ test (
265
+ 'setUser handles null user attributes when provided a AWSPinpointUserProfile' ,
266
+ () async {
267
+ endpointClient
268
+ ..channelType = channelType
269
+ ..address = address
270
+ ..optOut = optOut;
271
+
272
+ await endpointClient.setUser (
273
+ userId,
274
+ pinpointUserProfileNullUserAttribute,
275
+ );
276
+
277
+ final endpoint = endpointClient.getPublicEndpoint ();
278
+
279
+ expect (endpoint.address, address);
280
+ expect (endpoint.channelType, channelType);
281
+ expect (endpoint.optOut, optOut);
282
+
283
+ // Attributes
284
+ expect (endpoint.attributes, isNotNull);
285
+ final attributes = endpoint.attributes! ;
286
+
287
+ expect (attributes['name' ], [userProfile.name]);
288
+ expect (attributes['email' ], [userProfile.email]);
289
+ expect (attributes['plan' ], [userProfile.plan]);
290
+
291
+ // Demographic
292
+ expect (endpoint.demographic, isNotNull);
293
+ final demographic = endpoint.demographic! ;
294
+
295
+ expect (demographic.appVersion, mockDeviceContextInfo.appVersion);
296
+ expect (demographic.locale, mockDeviceContextInfo.locale);
297
+ expect (demographic.make, mockDeviceContextInfo.make);
298
+ expect (demographic.model, mockDeviceContextInfo.model);
299
+ expect (demographic.modelVersion, mockDeviceContextInfo.modelVersion);
300
+ expect (demographic.platform, mockDeviceContextInfo.platform! .name);
301
+ expect (
302
+ demographic.platformVersion,
303
+ mockDeviceContextInfo.platformVersion,
304
+ );
305
+
306
+ // Location
307
+ expect (endpoint.location, isNotNull);
308
+ final location = endpoint.location! ;
309
+
310
+ expect (location.city, userLocation.city);
311
+ expect (location.country, userLocation.country);
312
+ expect (location.latitude, userLocation.latitude);
313
+ expect (location.longitude, userLocation.longitude);
314
+ expect (location.postalCode, userLocation.postalCode);
315
+ expect (location.region, userLocation.region);
316
+
317
+ // User
318
+ expect (endpoint.user, isNotNull);
319
+ expect (endpoint.user! .userId, userId);
320
+
321
+ expect (endpoint.user! .userAttributes, isNull);
322
+ });
323
+
265
324
test (
266
325
'updateEndpoint throws AnalyticsException from unrecognized exceptions' ,
267
326
() async {
0 commit comments