forked from eatvio/eatvio_app
feat(tests): updated tests coverage to 66.5%
This commit is contained in:
@@ -9,10 +9,7 @@ import 'package:mockito/mockito.dart';
|
||||
|
||||
import 'my_recipes_cubit_test.mocks.dart';
|
||||
|
||||
@GenerateNiceMocks([
|
||||
MockSpec<MyRecipesRepository>(),
|
||||
MockSpec<AboutRecipeRepository>(),
|
||||
])
|
||||
@GenerateNiceMocks([MockSpec<MyRecipesRepository>(), MockSpec<AboutRecipeRepository>()])
|
||||
void main() {
|
||||
group('MyRecipesCubit', () {
|
||||
MyRecipesCubit? cubit;
|
||||
@@ -32,19 +29,13 @@ void main() {
|
||||
});
|
||||
|
||||
test('начальное состояние - loading', () {
|
||||
cubit = MyRecipesCubit(
|
||||
myRecipesRepository: mockMyRecipesRepository,
|
||||
aboutRecipeRepository: mockAboutRecipeRepository,
|
||||
);
|
||||
cubit = MyRecipesCubit(myRecipesRepository: mockMyRecipesRepository, aboutRecipeRepository: mockAboutRecipeRepository);
|
||||
|
||||
expect(cubit!.state, isA<MyRecipesStateLoading>());
|
||||
});
|
||||
|
||||
test('getMyRecipes - успешная загрузка активных рецептов', () async {
|
||||
cubit = MyRecipesCubit(
|
||||
myRecipesRepository: mockMyRecipesRepository,
|
||||
aboutRecipeRepository: mockAboutRecipeRepository,
|
||||
);
|
||||
cubit = MyRecipesCubit(myRecipesRepository: mockMyRecipesRepository, aboutRecipeRepository: mockAboutRecipeRepository);
|
||||
|
||||
final testRecipes = [
|
||||
const MyRecipeModel(
|
||||
@@ -64,8 +55,7 @@ void main() {
|
||||
),
|
||||
];
|
||||
|
||||
when(mockMyRecipesRepository.getMyRecipes())
|
||||
.thenAnswer((_) async => testRecipes);
|
||||
when(mockMyRecipesRepository.getMyRecipes()).thenAnswer((_) async => testRecipes);
|
||||
|
||||
await cubit!.getMyRecipes();
|
||||
|
||||
@@ -76,10 +66,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('setActiveState - фильтрует активные рецепты', () async {
|
||||
cubit = MyRecipesCubit(
|
||||
myRecipesRepository: mockMyRecipesRepository,
|
||||
aboutRecipeRepository: mockAboutRecipeRepository,
|
||||
);
|
||||
cubit = MyRecipesCubit(myRecipesRepository: mockMyRecipesRepository, aboutRecipeRepository: mockAboutRecipeRepository);
|
||||
|
||||
final testRecipes = [
|
||||
const MyRecipeModel(
|
||||
@@ -114,8 +101,7 @@ void main() {
|
||||
),
|
||||
];
|
||||
|
||||
when(mockMyRecipesRepository.getMyRecipes())
|
||||
.thenAnswer((_) async => testRecipes);
|
||||
when(mockMyRecipesRepository.getMyRecipes()).thenAnswer((_) async => testRecipes);
|
||||
|
||||
await cubit!.setActiveState();
|
||||
|
||||
@@ -126,10 +112,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('setArchivedState - фильтрует архивированные рецепты', () async {
|
||||
cubit = MyRecipesCubit(
|
||||
myRecipesRepository: mockMyRecipesRepository,
|
||||
aboutRecipeRepository: mockAboutRecipeRepository,
|
||||
);
|
||||
cubit = MyRecipesCubit(myRecipesRepository: mockMyRecipesRepository, aboutRecipeRepository: mockAboutRecipeRepository);
|
||||
|
||||
final testRecipes = [
|
||||
const MyRecipeModel(
|
||||
@@ -164,8 +147,7 @@ void main() {
|
||||
),
|
||||
];
|
||||
|
||||
when(mockMyRecipesRepository.getMyRecipes())
|
||||
.thenAnswer((_) async => testRecipes);
|
||||
when(mockMyRecipesRepository.getMyRecipes()).thenAnswer((_) async => testRecipes);
|
||||
|
||||
await cubit!.setArchivedState();
|
||||
|
||||
@@ -176,4 +158,3 @@ void main() {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user