Files
eatvio_app/test/features/consultant_rating/models/statistics_model_test.dart

76 lines
2.3 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:eatvio_app/features/consultant_rating/models/statistics_model.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('StatisticsModel', () {
test('создает StatisticsModel с правильными значениями', () {
final model = StatisticsModel(
countReferal: 10,
blogPostsCount: 5,
recipesCount: 3,
dietsCount: 2,
consultationsCount: 15,
qwe: 100,
refLink: 'https://example.com/ref',
);
expect(model.countReferal, 10);
expect(model.blogPostsCount, 5);
expect(model.recipesCount, 3);
expect(model.dietsCount, 2);
expect(model.consultationsCount, 15);
expect(model.qwe, 100);
expect(model.refLink, 'https://example.com/ref');
});
test('создает StatisticsModel с null значениями', () {
final model = StatisticsModel();
expect(model.countReferal, isNull);
expect(model.blogPostsCount, isNull);
expect(model.recipesCount, isNull);
expect(model.dietsCount, isNull);
expect(model.consultationsCount, isNull);
expect(model.qwe, isNull);
expect(model.refLink, isNull);
});
test('fromJson создает StatisticsModel из JSON', () {
final json = {
'count_referal': 10,
'count_blog_posts': 5,
'count_recipes': 3,
'count_diets': 2,
'count_consultants': 15,
'count_products_nutritional_values': 100,
'referral_link': 'https://example.com/ref',
};
final model = StatisticsModel.fromJson(json);
expect(model.countReferal, 10);
expect(model.blogPostsCount, 5);
expect(model.recipesCount, 3);
expect(model.dietsCount, 2);
expect(model.consultationsCount, 15);
expect(model.qwe, 100);
expect(model.refLink, 'https://example.com/ref');
});
test('fromJson создает StatisticsModel из JSON с null значениями', () {
final json = <String, dynamic>{};
final model = StatisticsModel.fromJson(json);
expect(model.countReferal, isNull);
expect(model.blogPostsCount, isNull);
expect(model.recipesCount, isNull);
expect(model.dietsCount, isNull);
expect(model.consultationsCount, isNull);
expect(model.qwe, isNull);
expect(model.refLink, isNull);
});
});
}