Skip to content

Commit

Permalink
Complete bloc tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bizz84 committed Oct 28, 2019
1 parent 3b6c60d commit e1c8582
Showing 1 changed file with 42 additions and 6 deletions.
48 changes: 42 additions & 6 deletions test/email_sign_in_bloc_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart';
import 'package:time_tracker_flutter_course/app/sign_in/email_sign_in_bloc.dart';
import 'package:time_tracker_flutter_course/app/sign_in/email_sign_in_model.dart';

Expand All @@ -17,10 +19,44 @@ void main() {
bloc.dispose();
});

test('WHEN email is updated'
'AND password is updated'
'AND submit is called'
'THEN modelStream emits the correct events', () async {
expect(bloc.modelStream, emits(EmailSignInModel()));
test(
'WHEN email is updated'
'AND password is updated'
'AND submit is called'
'THEN modelStream emits the correct events', () async {
when(mockAuth.signInWithEmailAndPassword(any, any))
.thenThrow(PlatformException(code: 'ERROR'));
expect(
bloc.modelStream,
emitsInOrder([
EmailSignInModel(),
EmailSignInModel(email: '[email protected]'),
EmailSignInModel(
email: '[email protected]',
password: 'password',
),
EmailSignInModel(
email: '[email protected]',
password: 'password',
submitted: true,
isLoading: true,
),
EmailSignInModel(
email: '[email protected]',
password: 'password',
submitted: true,
isLoading: false,
),
])
);

bloc.updateEmail('[email protected]');

bloc.updatePassword('password');

try {
await bloc.submit();
} catch (_) {
}
});
}
}

0 comments on commit e1c8582

Please sign in to comment.