forked from eatvio/eatvio_app
47 lines
1.3 KiB
Dart
47 lines
1.3 KiB
Dart
import 'package:eatvio_app/features/consultant_rating/models/rating_model.dart';
|
||
import 'package:flutter_test/flutter_test.dart';
|
||
|
||
void main() {
|
||
group('RatingModel', () {
|
||
test('создает RatingModel с правильными значениями', () {
|
||
final model = RatingModel(
|
||
date: DateTime(2024, 1, 1),
|
||
type: RatingEnum.addedRecipe,
|
||
amount: 10,
|
||
);
|
||
|
||
expect(model.amount, 10);
|
||
expect(model.type, RatingEnum.addedRecipe);
|
||
});
|
||
|
||
test('fromJson создает RatingModel из JSON', () {
|
||
final json = {
|
||
'created_at': '2024-01-01T00:00:00Z',
|
||
'log_data': 'ADDED_RECIPE',
|
||
'log_scores': 10,
|
||
};
|
||
|
||
final model = RatingModel.fromJson(json);
|
||
|
||
expect(model.amount, 10);
|
||
expect(model.type, RatingEnum.addedRecipe);
|
||
});
|
||
});
|
||
|
||
group('RatingPaginationModel', () {
|
||
test('создает RatingPaginationModel с правильными значениями', () {
|
||
final rating = RatingModel(
|
||
date: DateTime(2024, 1, 1),
|
||
type: RatingEnum.addedRecipe,
|
||
amount: 10,
|
||
);
|
||
|
||
final pagination = RatingPaginationModel(data: [rating]);
|
||
|
||
expect(pagination.data.length, 1);
|
||
expect(pagination.data.first.amount, 10);
|
||
});
|
||
});
|
||
}
|
||
|