Skip to content

Commit

Permalink
chore: remove mock state machine from test
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan-Nelson committed Aug 31, 2023
1 parent 05c5ff9 commit eb246bf
Showing 1 changed file with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<CognitoIdentityProviderClient>(
MockCognitoIdentityProviderClient(
Expand All @@ -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(
Expand Down Expand Up @@ -202,6 +199,16 @@ void main() {
});

test('refreshes token before calling Cognito', () async {
stateMachine = CognitoAuthStateMachine()
..addInstance<CognitoIdentityProviderClient>(
MockCognitoIdentityProviderClient(
getUser: () async => GetUserResponse(
userAttributes: [],
username: username,
),
),
);

final secureStorage = MockSecureStorage();
SecureStorageInterface storageFactory(scope) => secureStorage;
seedStorage(
Expand Down

0 comments on commit eb246bf

Please sign in to comment.