master #81
@ -26,25 +26,22 @@ import 'package:example_router/presentation/features/sign_up/blocs/custom_sign_u
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:wyatt_architecture/wyatt_architecture.dart';
|
||||||
import 'package:wyatt_authentication_bloc/wyatt_authentication_bloc.dart';
|
import 'package:wyatt_authentication_bloc/wyatt_authentication_bloc.dart';
|
||||||
import 'package:wyatt_form_bloc/wyatt_form_bloc.dart';
|
import 'package:wyatt_form_bloc/wyatt_form_bloc.dart';
|
||||||
import 'package:wyatt_type_utils/wyatt_type_utils.dart';
|
import 'package:wyatt_type_utils/wyatt_type_utils.dart';
|
||||||
import 'package:wyatt_architecture/wyatt_architecture.dart';
|
|
||||||
|
|
||||||
FutureOrResult<int?> onAccountChanges(
|
FutureOrResult<int?> onAccountChanges(
|
||||||
AuthenticationRepository<int> repo,
|
AuthenticationRepository<int> repo,
|
||||||
AuthChangeEvent? authEvent,
|
AuthChangeEvent? authEvent,
|
||||||
) async {
|
) async {
|
||||||
if (authEvent is SignInAuthChangeEvent || authEvent is RefreshAuthChangeEvent) {
|
|
||||||
final id = Random().nextInt(1000);
|
final id = Random().nextInt(1000);
|
||||||
final token =
|
final token =
|
||||||
await repo.getIdentityToken().fold((value) => value, (error) => 'null');
|
await repo.getIdentityToken().fold((value) => value, (error) => 'null');
|
||||||
|
|
||||||
debugPrint('onAccountChanges: ${authEvent?.account}, type: ${authEvent.runtimeType}, token: $token, generatedId: $id');
|
debugPrint(
|
||||||
|
'onAccountChanges: ${authEvent?.account}, type: ${authEvent.runtimeType}, token: $token, generatedId: $id');
|
||||||
return Ok<int, AppException>(id);
|
return Ok<int, AppException>(id);
|
||||||
} else {
|
|
||||||
return Err(ClientException('Not supported auth change logic'));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class App extends StatelessWidget {
|
class App extends StatelessWidget {
|
||||||
|
@ -579,11 +579,11 @@ void main() {
|
|||||||
[
|
[
|
||||||
FormInput(
|
FormInput(
|
||||||
AuthFormField.email,
|
AuthFormField.email,
|
||||||
const Email.dirty(validEmailString),
|
const Email.pure(),
|
||||||
),
|
),
|
||||||
FormInput(
|
FormInput(
|
||||||
AuthFormField.password,
|
AuthFormField.password,
|
||||||
const Password.dirty(validPasswordString),
|
const Password.pure(),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
name: AuthFormName.signInForm,
|
name: AuthFormName.signInForm,
|
||||||
@ -595,11 +595,11 @@ void main() {
|
|||||||
[
|
[
|
||||||
FormInput(
|
FormInput(
|
||||||
AuthFormField.email,
|
AuthFormField.email,
|
||||||
const Email.dirty(validEmailString),
|
const Email.pure(),
|
||||||
),
|
),
|
||||||
FormInput(
|
FormInput(
|
||||||
AuthFormField.password,
|
AuthFormField.password,
|
||||||
const Password.dirty(validPasswordString),
|
const Password.pure(),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
name: AuthFormName.signInForm,
|
name: AuthFormName.signInForm,
|
||||||
@ -643,11 +643,11 @@ void main() {
|
|||||||
[
|
[
|
||||||
FormInput(
|
FormInput(
|
||||||
AuthFormField.email,
|
AuthFormField.email,
|
||||||
const Email.dirty(validEmailString),
|
const Email.pure(),
|
||||||
),
|
),
|
||||||
FormInput(
|
FormInput(
|
||||||
AuthFormField.password,
|
AuthFormField.password,
|
||||||
const Password.dirty(validPasswordString),
|
const Password.pure(),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
name: AuthFormName.signInForm,
|
name: AuthFormName.signInForm,
|
||||||
@ -659,11 +659,11 @@ void main() {
|
|||||||
[
|
[
|
||||||
FormInput(
|
FormInput(
|
||||||
AuthFormField.email,
|
AuthFormField.email,
|
||||||
const Email.dirty(validEmailString),
|
const Email.pure(),
|
||||||
),
|
),
|
||||||
FormInput(
|
FormInput(
|
||||||
AuthFormField.password,
|
AuthFormField.password,
|
||||||
const Password.dirty(validPasswordString),
|
const Password.pure(),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
name: AuthFormName.signInForm,
|
name: AuthFormName.signInForm,
|
||||||
|
@ -65,6 +65,13 @@ void main() {
|
|||||||
),
|
),
|
||||||
).thenAnswer((_) async => Ok(account));
|
).thenAnswer((_) async => Ok(account));
|
||||||
|
|
||||||
|
when(
|
||||||
|
() => authenticationRepository.signInWithEmailAndPassword(
|
||||||
|
email: any(named: 'email'),
|
||||||
|
password: any(named: 'password'),
|
||||||
|
),
|
||||||
|
).thenAnswer((_) async => Ok(account));
|
||||||
|
|
||||||
when(
|
when(
|
||||||
() => authenticationRepository.formRepository,
|
() => authenticationRepository.formRepository,
|
||||||
).thenAnswer((_) => formRepository);
|
).thenAnswer((_) => formRepository);
|
||||||
@ -258,13 +265,13 @@ void main() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
group('submit', () {
|
group('signUpWithEmailPassword', () {
|
||||||
blocTest<SignUpCubit<int>, SignUpState>(
|
blocTest<SignUpCubit<int>, SignUpState>(
|
||||||
'does nothing when status is not validated',
|
'does nothing when status is not validated',
|
||||||
build: () => SignUpCubit(
|
build: () => SignUpCubit(
|
||||||
authenticationRepository: authenticationRepository,
|
authenticationRepository: authenticationRepository,
|
||||||
),
|
),
|
||||||
act: (cubit) => cubit.submit(),
|
act: (cubit) => cubit.signUpWithEmailPassword(),
|
||||||
expect: () => const <SignUpState>[],
|
expect: () => const <SignUpState>[],
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -308,7 +315,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
status: FormStatus.valid,
|
status: FormStatus.valid,
|
||||||
),
|
),
|
||||||
act: (cubit) => cubit.submit(),
|
act: (cubit) => cubit.signUpWithEmailPassword(),
|
||||||
verify: (_) {
|
verify: (_) {
|
||||||
verify(
|
verify(
|
||||||
() => authenticationRepository.signUp(
|
() => authenticationRepository.signUp(
|
||||||
@ -360,7 +367,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
status: FormStatus.valid,
|
status: FormStatus.valid,
|
||||||
),
|
),
|
||||||
act: (cubit) => cubit.submit(),
|
act: (cubit) => cubit.signUpWithEmailPassword(),
|
||||||
expect: () => <SignUpState>[
|
expect: () => <SignUpState>[
|
||||||
SignUpState(
|
SignUpState(
|
||||||
form: WyattFormImpl(
|
form: WyattFormImpl(
|
||||||
@ -444,7 +451,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
status: FormStatus.valid,
|
status: FormStatus.valid,
|
||||||
),
|
),
|
||||||
act: (cubit) => cubit.submit(),
|
act: (cubit) => cubit.signUpWithEmailPassword(),
|
||||||
expect: () => <SignUpState>[
|
expect: () => <SignUpState>[
|
||||||
SignUpState(
|
SignUpState(
|
||||||
form: WyattFormImpl(
|
form: WyattFormImpl(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user