From eb246bff1c55091041c45604602b01e3a414641b Mon Sep 17 00:00:00 2001 From: Jordan Nelson Date: Thu, 31 Aug 2023 14:44:50 -0400 Subject: [PATCH] chore: remove mock state machine from test --- .../plugin/fetch_user_attributes_test.dart | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/packages/auth/amplify_auth_cognito_test/test/plugin/fetch_user_attributes_test.dart b/packages/auth/amplify_auth_cognito_test/test/plugin/fetch_user_attributes_test.dart index 0e299171f71..96f0f515e77 100644 --- a/packages/auth/amplify_auth_cognito_test/test/plugin/fetch_user_attributes_test.dart +++ b/packages/auth/amplify_auth_cognito_test/test/plugin/fetch_user_attributes_test.dart @@ -93,7 +93,11 @@ void main() { late AmplifyAuthCognitoDart plugin; group('fetchUserAttributes', () { - setUp(() { + tearDown(() async { + await plugin.close(); + }); + + test('converts user attributes correctly', () async { stateMachine = MockCognitoAuthStateMachine() ..addInstance( MockCognitoIdentityProviderClient( @@ -107,13 +111,6 @@ void main() { ), ); plugin = AmplifyAuthCognitoDart()..stateMachine = stateMachine; - }); - - tearDown(() async { - await plugin.close(); - }); - - test('converts user attributes correctly', () async { final res = await plugin.fetchUserAttributes(); final expected = [ AuthUserAttribute( @@ -202,6 +199,16 @@ void main() { }); test('refreshes token before calling Cognito', () async { + stateMachine = CognitoAuthStateMachine() + ..addInstance( + MockCognitoIdentityProviderClient( + getUser: () async => GetUserResponse( + userAttributes: [], + username: username, + ), + ), + ); + final secureStorage = MockSecureStorage(); SecureStorageInterface storageFactory(scope) => secureStorage; seedStorage(