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 = {}; 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); }); test('toJson serializes StatisticsModel correctly', () { final model = StatisticsModel( countReferal: 10, blogPostsCount: 5, recipesCount: 3, dietsCount: 2, consultationsCount: 15, qwe: 100, refLink: 'https://example.com/ref', ); final json = model.toJson(); expect(json['count_referal'], 10); expect(json['count_blog_posts'], 5); expect(json['count_recipes'], 3); expect(json['count_diets'], 2); expect(json['count_consultants'], 15); expect(json['count_products_nutritional_values'], 100); expect(json['referral_link'], 'https://example.com/ref'); }); test('toJson omits null fields', () { final model = StatisticsModel(); final json = model.toJson(); expect(json['count_referal'], isNull); expect(json['count_blog_posts'], isNull); expect(json['referral_link'], isNull); }); }); }