Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
  • Loading branch information
itome committed Oct 3, 2023
1 parent 2461313 commit 50add9c
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions auth0_flutter/test/web/extensions/user_profile_extension_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,61 @@ void main() {
expect(result.customClaims, customClaims);
});

test('creates UserProfile from claims with stringified email_verified',
() async {
const Map<String, dynamic> claims = {
...requiredValues,
PublicClaims.name: 'John Alexander Doe',
PublicClaims.givenName: 'John',
PublicClaims.familyName: 'Doe',
PublicClaims.middleName: 'Alexander',
PublicClaims.nickname: 'johnny',
PublicClaims.preferredUsername: 'johnnyD',
PublicClaims.profile: 'https://example.com/profile',
PublicClaims.picture: 'https://example.com/picture.png',
PublicClaims.website: 'https://example.com',
PublicClaims.email: 'john.doe@example.com',
PublicClaims.emailVerified: 'true',
PublicClaims.gender: 'male',
PublicClaims.birthdate: '01-01-2000',
PublicClaims.zoneinfo: 'America/Chicago',
PublicClaims.locale: 'en-US',
PublicClaims.phoneNumber: '111111111',
PublicClaims.phoneNumberVerified: true,
PublicClaims.address: {'street': '1 Foo St', 'zip_code': '11111-1111'},
PublicClaims.updatedAt: '2023-02-28T15:08:56+00:00',
'foo': 'bar'
};

final result = UserProfileExtension.fromClaims(claims);

expect(result.name, claims[PublicClaims.name]);
expect(result.givenName, claims[PublicClaims.givenName]);
expect(result.familyName, claims[PublicClaims.familyName]);
expect(result.middleName, claims[PublicClaims.middleName]);
expect(result.nickname, claims[PublicClaims.nickname]);
expect(result.preferredUsername, claims[PublicClaims.preferredUsername]);
expect(
result.profileUrl, Uri.parse(claims[PublicClaims.profile] as String));
expect(
result.pictureUrl, Uri.parse(claims[PublicClaims.picture] as String));
expect(
result.websiteUrl, Uri.parse(claims[PublicClaims.website] as String));
expect(result.email, claims[PublicClaims.email]);
expect(result.isEmailVerified, claims[PublicClaims.emailVerified]);
expect(result.gender, claims[PublicClaims.gender]);
expect(result.birthdate, claims[PublicClaims.birthdate]);
expect(result.zoneinfo, claims[PublicClaims.zoneinfo]);
expect(result.locale, claims[PublicClaims.locale]);
expect(result.phoneNumber, claims[PublicClaims.phoneNumber]);
expect(result.isPhoneNumberVerified,
claims[PublicClaims.phoneNumberVerified]);
expect(result.address, claims[PublicClaims.address]);
expect(result.updatedAt,
DateTime.parse(claims[PublicClaims.updatedAt] as String));
expect(result.customClaims?['foo'], claims['foo']);
});

test('throws exception with invalid profile URL', () async {
const Map<String, dynamic> claims = {
...requiredValues,
Expand Down

0 comments on commit 50add9c

Please sign in to comment.