forked from eatvio/eatvio_app
feat(dependencies): add rxdart package and improve string extension methods for better handling of empty strings and gender parsing
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
import 'package:eatvio_app/features/diary/models/consultant_comment_model.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
group('ConsultantCommentModel', () {
|
||||
test('создает ConsultantCommentModel с дефолтными значениями', () {
|
||||
final model = ConsultantCommentModel();
|
||||
|
||||
expect(model.comment, isNull);
|
||||
expect(model.mealsComments, isEmpty);
|
||||
expect(model.portions, isEmpty);
|
||||
});
|
||||
|
||||
test('создает ConsultantCommentModel с комментариями', () {
|
||||
final model = ConsultantCommentModel(
|
||||
comment: 'General comment',
|
||||
mealsComments: {
|
||||
'breakfast': MealCommentModel(
|
||||
comment: 'Breakfast comment',
|
||||
typeNumber: 1,
|
||||
),
|
||||
},
|
||||
portions: [
|
||||
PortionCommentModel(
|
||||
comment: 'Portion comment',
|
||||
id: 1,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
expect(model.comment, 'General comment');
|
||||
expect(model.mealsComments.length, 1);
|
||||
expect(model.portions.length, 1);
|
||||
});
|
||||
});
|
||||
|
||||
group('MealCommentModel', () {
|
||||
test('создает MealCommentModel с правильными значениями', () {
|
||||
final model = MealCommentModel(
|
||||
comment: 'Test comment',
|
||||
typeNumber: 1,
|
||||
);
|
||||
|
||||
expect(model.comment, 'Test comment');
|
||||
expect(model.typeNumber, 1);
|
||||
});
|
||||
});
|
||||
|
||||
group('PortionCommentModel', () {
|
||||
test('создает PortionCommentModel с правильными значениями', () {
|
||||
final model = PortionCommentModel(
|
||||
comment: 'Portion comment',
|
||||
id: 1,
|
||||
);
|
||||
|
||||
expect(model.comment, 'Portion comment');
|
||||
expect(model.id, 1);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
37
test/features/diary/models/consultant_review_model_test.dart
Normal file
37
test/features/diary/models/consultant_review_model_test.dart
Normal file
@@ -0,0 +1,37 @@
|
||||
import 'package:eatvio_app/features/diary/models/consultant_review_model.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
group('ConsultantReviewModel', () {
|
||||
test('создает ConsultantReviewModel с правильными значениями', () {
|
||||
final comments = ConsultantComments(
|
||||
dayComment: 'Day comment',
|
||||
mealsComments: [
|
||||
MealComment(
|
||||
comment: 'Meal comment',
|
||||
typeNo: 1,
|
||||
),
|
||||
],
|
||||
portionsComments: [
|
||||
PortionComment(
|
||||
portionId: 1,
|
||||
comment: 'Portion comment',
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
final model = ConsultantReviewModel(
|
||||
planName: 'Test Plan',
|
||||
planDuration: 30,
|
||||
currentPlanDay: 5,
|
||||
consultantComments: comments,
|
||||
);
|
||||
|
||||
expect(model.planName, 'Test Plan');
|
||||
expect(model.planDuration, 30);
|
||||
expect(model.currentPlanDay, 5);
|
||||
expect(model.consultantComments.dayComment, 'Day comment');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
23
test/features/diary/models/create_day_model_test.dart
Normal file
23
test/features/diary/models/create_day_model_test.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
import 'package:eatvio_app/features/diary/models/create_day_model.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
group('CreateDayModel', () {
|
||||
test('создает CreateDayModel с правильными значениями', () {
|
||||
final model = CreateDayModel(day: '2024-01-01');
|
||||
|
||||
expect(model.day, '2024-01-01');
|
||||
});
|
||||
|
||||
test('fromJson создает CreateDayModel из JSON', () {
|
||||
final json = {
|
||||
'day': '2024-01-01',
|
||||
};
|
||||
|
||||
final model = CreateDayModel.fromJson(json);
|
||||
|
||||
expect(model.day, '2024-01-01');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
29
test/features/diary/models/finish_diary_day_model_test.dart
Normal file
29
test/features/diary/models/finish_diary_day_model_test.dart
Normal file
@@ -0,0 +1,29 @@
|
||||
import 'package:eatvio_app/features/diary/models/finish_diary_day_model.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
group('FinishDiaryDayModel', () {
|
||||
test('создает FinishDiaryDayModel с правильными значениями', () {
|
||||
const model = FinishDiaryDayModel(
|
||||
wakeUp: '08:00',
|
||||
retire: '22:00',
|
||||
comment: 'Test comment',
|
||||
);
|
||||
|
||||
expect(model.wakeUp, '08:00');
|
||||
expect(model.retire, '22:00');
|
||||
expect(model.comment, 'Test comment');
|
||||
});
|
||||
|
||||
test('создает FinishDiaryDayModel без комментария', () {
|
||||
const model = FinishDiaryDayModel(
|
||||
wakeUp: '08:00',
|
||||
retire: '22:00',
|
||||
comment: null,
|
||||
);
|
||||
|
||||
expect(model.comment, isNull);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
61
test/features/diary/models/nutrition_model_test.dart
Normal file
61
test/features/diary/models/nutrition_model_test.dart
Normal file
@@ -0,0 +1,61 @@
|
||||
import 'package:eatvio_app/features/diary/models/nutrition_model.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
group('NutritionModel', () {
|
||||
test('создает NutritionModel с правильными значениями', () {
|
||||
const model = NutritionModel(
|
||||
energy: 2000.0,
|
||||
proteins: 100.0,
|
||||
fats: 50.0,
|
||||
carbohydrates: 250.0,
|
||||
);
|
||||
|
||||
expect(model.energy, 2000.0);
|
||||
expect(model.proteins, 100.0);
|
||||
expect(model.fats, 50.0);
|
||||
expect(model.carbohydrates, 250.0);
|
||||
});
|
||||
|
||||
test('fromJson создает NutritionModel из JSON', () {
|
||||
final json = {
|
||||
'energy': 2000.0,
|
||||
'proteins': 100.0,
|
||||
'fats': 50.0,
|
||||
'carbohydrates': 250.0,
|
||||
};
|
||||
|
||||
final model = NutritionModel.fromJson(json);
|
||||
|
||||
expect(model.energy, 2000.0);
|
||||
expect(model.proteins, 100.0);
|
||||
});
|
||||
});
|
||||
|
||||
group('NutritionDataModel', () {
|
||||
test('создает NutritionDataModel с правильными значениями', () {
|
||||
const intake = NutritionModel(
|
||||
energy: 2000.0,
|
||||
proteins: 100.0,
|
||||
fats: 50.0,
|
||||
carbohydrates: 250.0,
|
||||
);
|
||||
|
||||
const recommendation = NutritionModel(
|
||||
energy: 2500.0,
|
||||
proteins: 120.0,
|
||||
fats: 60.0,
|
||||
carbohydrates: 300.0,
|
||||
);
|
||||
|
||||
const model = NutritionDataModel(
|
||||
dailyNutritionIntake: intake,
|
||||
dailyNutritionRecommendation: recommendation,
|
||||
);
|
||||
|
||||
expect(model.dailyNutritionIntake.energy, 2000.0);
|
||||
expect(model.dailyNutritionRecommendation.energy, 2500.0);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import 'package:eatvio_app/features/diary/models/product_moderation_model.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
group('ProductModerationModel', () {
|
||||
test('создает ProductModerationModel с правильными значениями', () {
|
||||
const model = ProductModerationModel(
|
||||
name: 'Apple',
|
||||
energy: 52.0,
|
||||
proteins: 0.3,
|
||||
fats: 0.2,
|
||||
carbohydrates: 14.0,
|
||||
);
|
||||
|
||||
expect(model.name, 'Apple');
|
||||
expect(model.energy, 52.0);
|
||||
expect(model.proteins, 0.3);
|
||||
expect(model.fats, 0.2);
|
||||
expect(model.carbohydrates, 14.0);
|
||||
});
|
||||
|
||||
test('fromJson создает ProductModerationModel из JSON', () {
|
||||
final json = {
|
||||
'name': 'Apple',
|
||||
'energy_on_100gr': 52.0,
|
||||
'proteins_on_100gr': 0.3,
|
||||
'fats_on_100gr': 0.2,
|
||||
'carbohydrates_on_100gr': 14.0,
|
||||
};
|
||||
|
||||
final model = ProductModerationModel.fromJson(json);
|
||||
|
||||
expect(model.name, 'Apple');
|
||||
expect(model.energy, 52.0);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user