test(auth): add tests for the SignUpCubit update method
This commit is contained in:
parent
d5698fbffc
commit
54002beaab
@ -481,5 +481,178 @@ void main() {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
group('update', () {
|
||||||
|
final inputsA = <
|
||||||
|
FormInput<dynamic, FormInputValidator<dynamic, ValidationError>,
|
||||||
|
dynamic>>[
|
||||||
|
FormInput(AuthFormField.email, const Email.pure()),
|
||||||
|
FormInput(AuthFormField.password, const Password.pure())
|
||||||
|
];
|
||||||
|
|
||||||
|
final inputsB = <
|
||||||
|
FormInput<dynamic, FormInputValidator<dynamic, ValidationError>,
|
||||||
|
dynamic>>[
|
||||||
|
FormInput('name', const Name.pure()),
|
||||||
|
FormInput('phone', const Phone.pure()),
|
||||||
|
];
|
||||||
|
|
||||||
|
final inputsC = <
|
||||||
|
FormInput<dynamic, FormInputValidator<dynamic, ValidationError>,
|
||||||
|
dynamic>>[
|
||||||
|
FormInput(AuthFormField.email, const Email.pure()),
|
||||||
|
FormInput(AuthFormField.password, const Password.pure()),
|
||||||
|
FormInput('name', const Name.pure()),
|
||||||
|
FormInput('phone', const Phone.pure()),
|
||||||
|
];
|
||||||
|
|
||||||
|
blocTest<SignUpCubit<int>, SignUpState>(
|
||||||
|
'emits no state when apply intersection with the same form',
|
||||||
|
build: () => SignUpCubit(
|
||||||
|
authenticationRepository: authenticationRepository,
|
||||||
|
),
|
||||||
|
seed: () => SignUpState(
|
||||||
|
form: WyattFormImpl(
|
||||||
|
inputsA,
|
||||||
|
name: AuthFormName.signUpForm,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
act: (cubit) => cubit.update(
|
||||||
|
WyattFormImpl(inputsA, name: 'otherSignUpForm'),
|
||||||
|
operation: SetOperation.intersection,
|
||||||
|
),
|
||||||
|
expect: () => <SignUpState>[],
|
||||||
|
);
|
||||||
|
|
||||||
|
blocTest<SignUpCubit<int>, SignUpState>(
|
||||||
|
'emits no state when apply intersection with a form that '
|
||||||
|
'contains every inputs of actual form',
|
||||||
|
build: () => SignUpCubit(
|
||||||
|
authenticationRepository: authenticationRepository,
|
||||||
|
),
|
||||||
|
seed: () => SignUpState(
|
||||||
|
form: WyattFormImpl(
|
||||||
|
inputsA,
|
||||||
|
name: AuthFormName.signUpForm,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
act: (cubit) => cubit.update(
|
||||||
|
WyattFormImpl(inputsC, name: 'otherSignUpForm'),
|
||||||
|
operation: SetOperation.intersection,
|
||||||
|
),
|
||||||
|
expect: () => <SignUpState>[],
|
||||||
|
);
|
||||||
|
|
||||||
|
blocTest<SignUpCubit<int>, SignUpState>(
|
||||||
|
'emits the form intersection when apply '
|
||||||
|
'intersection with a smaller form',
|
||||||
|
build: () => SignUpCubit(
|
||||||
|
authenticationRepository: authenticationRepository,
|
||||||
|
),
|
||||||
|
seed: () => SignUpState(
|
||||||
|
form: WyattFormImpl(
|
||||||
|
inputsC,
|
||||||
|
name: AuthFormName.signUpForm,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
act: (cubit) => cubit.update(
|
||||||
|
WyattFormImpl(inputsA, name: 'otherSignUpForm'),
|
||||||
|
operation: SetOperation.intersection,
|
||||||
|
),
|
||||||
|
expect: () => <SignUpState>[
|
||||||
|
SignUpState(
|
||||||
|
form: WyattFormImpl(
|
||||||
|
inputsA,
|
||||||
|
name: AuthFormName.signUpForm,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
blocTest<SignUpCubit<int>, SignUpState>(
|
||||||
|
'emits no state when apply union with the same form',
|
||||||
|
build: () => SignUpCubit(
|
||||||
|
authenticationRepository: authenticationRepository,
|
||||||
|
),
|
||||||
|
seed: () => SignUpState(
|
||||||
|
form: WyattFormImpl(
|
||||||
|
inputsA,
|
||||||
|
name: AuthFormName.signUpForm,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
act: (cubit) => cubit.update(
|
||||||
|
WyattFormImpl(inputsA, name: 'otherSignUpForm'),
|
||||||
|
operation: SetOperation.union,
|
||||||
|
),
|
||||||
|
expect: () => <SignUpState>[],
|
||||||
|
);
|
||||||
|
|
||||||
|
blocTest<SignUpCubit<int>, SignUpState>(
|
||||||
|
'emits the form union when apply '
|
||||||
|
'union with an another form',
|
||||||
|
build: () => SignUpCubit(
|
||||||
|
authenticationRepository: authenticationRepository,
|
||||||
|
),
|
||||||
|
seed: () => SignUpState(
|
||||||
|
form: WyattFormImpl(
|
||||||
|
inputsA,
|
||||||
|
name: AuthFormName.signUpForm,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
act: (cubit) => cubit.update(
|
||||||
|
WyattFormImpl(inputsB, name: 'otherSignUpForm'),
|
||||||
|
operation: SetOperation.union,
|
||||||
|
),
|
||||||
|
expect: () => <SignUpState>[
|
||||||
|
SignUpState(
|
||||||
|
form: WyattFormImpl(
|
||||||
|
inputsC,
|
||||||
|
name: AuthFormName.signUpForm,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
blocTest<SignUpCubit<int>, SignUpState>(
|
||||||
|
'emits no state when apply replace with the same form',
|
||||||
|
build: () => SignUpCubit(
|
||||||
|
authenticationRepository: authenticationRepository,
|
||||||
|
),
|
||||||
|
seed: () => SignUpState(
|
||||||
|
form: WyattFormImpl(
|
||||||
|
inputsA,
|
||||||
|
name: AuthFormName.signUpForm,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
act: (cubit) => cubit.update(
|
||||||
|
WyattFormImpl(inputsA, name: AuthFormName.signUpForm),
|
||||||
|
),
|
||||||
|
expect: () => <SignUpState>[],
|
||||||
|
);
|
||||||
|
|
||||||
|
blocTest<SignUpCubit<int>, SignUpState>(
|
||||||
|
'emits a state with a new form after the replacement',
|
||||||
|
build: () => SignUpCubit(
|
||||||
|
authenticationRepository: authenticationRepository,
|
||||||
|
),
|
||||||
|
seed: () => SignUpState(
|
||||||
|
form: WyattFormImpl(
|
||||||
|
inputsA,
|
||||||
|
name: AuthFormName.signUpForm,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
act: (cubit) => cubit.update(
|
||||||
|
WyattFormImpl(inputsC, name: AuthFormName.signUpForm),
|
||||||
|
),
|
||||||
|
expect: () => <SignUpState>[
|
||||||
|
SignUpState(
|
||||||
|
form: WyattFormImpl(
|
||||||
|
inputsC,
|
||||||
|
name: AuthFormName.signUpForm,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user