forked from eatvio/eatvio_app
chore(tests): remove unused tests and clean up test files for MyDietsRepository and MyPlansCubit
This commit is contained in:
@@ -8,83 +8,6 @@ import 'package:mockito/mockito.dart';
|
||||
|
||||
import 'my_diets_repository_test.mocks.dart';
|
||||
|
||||
@GenerateNiceMocks([MockSpec<MyDietsService>()])
|
||||
void main() {
|
||||
group('MyDietsRepository', () {
|
||||
late MyDietsRepository repository;
|
||||
late MockMyDietsService mockService;
|
||||
|
||||
setUp(() {
|
||||
mockService = MockMyDietsService();
|
||||
repository = MyDietsRepository(myDietsService: mockService);
|
||||
});
|
||||
|
||||
test('deleteDiet - успешное удаление диеты', () async {
|
||||
const dietId = 1;
|
||||
|
||||
when(mockService.deleteDiet(dietId: dietId))
|
||||
.thenAnswer((_) async => Future.value());
|
||||
|
||||
await repository.deleteDiet(dietId);
|
||||
|
||||
verify(mockService.deleteDiet(dietId: dietId)).called(1);
|
||||
});
|
||||
|
||||
test('getDiets - успешное получение диет', () async {
|
||||
const pagination = DietsPagination(
|
||||
data: [],
|
||||
links: Links(
|
||||
first: 'https://example.com?page=1',
|
||||
last: 'https://example.com?page=1',
|
||||
prev: null,
|
||||
next: null,
|
||||
),
|
||||
meta: Meta(
|
||||
currentPage: 1,
|
||||
from: 1,
|
||||
lastPage: 1,
|
||||
links: [],
|
||||
perPage: 10,
|
||||
to: 1,
|
||||
total: 0,
|
||||
),
|
||||
);
|
||||
|
||||
when(mockService.getDiets(
|
||||
page: 1,
|
||||
query: null,
|
||||
types: null,
|
||||
duration: null,
|
||||
sorting: null,
|
||||
state: null,
|
||||
)).thenAnswer((_) async => pagination);
|
||||
|
||||
final result = await repository.getDiets();
|
||||
|
||||
expect(result, equals(pagination));
|
||||
verify(mockService.getDiets(
|
||||
page: 1,
|
||||
query: null,
|
||||
types: null,
|
||||
duration: null,
|
||||
sorting: null,
|
||||
state: null,
|
||||
)).called(1);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
import 'package:eatvio_app/core/models/pagination_model.dart';
|
||||
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
|
||||
import 'package:eatvio_app/features/my_diets/repositories/my_diets_repository.dart';
|
||||
import 'package:eatvio_app/features/my_diets/services/my_diets_service.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mockito/annotations.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
|
||||
import 'my_diets_repository_test.mocks.dart';
|
||||
|
||||
@GenerateNiceMocks([MockSpec<MyDietsService>()])
|
||||
void main() {
|
||||
group('MyDietsRepository', () {
|
||||
@@ -287,4 +210,3 @@ void main() {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user