feat(tests): updated tests coverage to 66.5%

This commit is contained in:
misha
2026-01-14 18:47:11 +03:00
parent 497ff19cfa
commit 13ccf56df0
102 changed files with 10146 additions and 379 deletions

View File

@@ -46,6 +46,32 @@ void main() {
expect(model.grInPortion, 100);
expect(model.energyOn100Gr, 52.0);
});
test('toJson serializes GlossaryModel correctly', () {
const model = GlossaryModel(
id: 1,
name: 'Apple',
grInPortion: 100,
energyOn100Gr: 52.0,
proteinsOn100Gr: 0.3,
fatsOn100Gr: 0.2,
carbohydratesOn100Gr: 14.0,
energyOnPortion: 52.0,
proteinsOnPortion: 0.3,
fatsOnPortion: 0.2,
carbohydratesOnPortion: 14.0,
);
final json = model.toJson();
expect(json['id'], 1);
expect(json['name'], 'Apple');
expect(json['portion_mass_gr'], 100);
expect(json['energy_on_100gr'], 52.0);
expect(json['proteins_on_100gr'], 0.3);
expect(json['fats_on_100gr'], 0.2);
expect(json['carbohydrates_on_100gr'], 14.0);
});
});
group('GlossaryPaginationModel', () {
@@ -94,6 +120,29 @@ void main() {
expect(pagination.glossariesList.length, 1);
expect(pagination.glossariesList.first.id, 1);
});
test('toJson serializes GlossaryPaginationModel correctly', () {
const glossary = GlossaryModel(
id: 1,
name: 'Apple',
grInPortion: 100,
energyOn100Gr: 52.0,
proteinsOn100Gr: 0.3,
fatsOn100Gr: 0.2,
carbohydratesOn100Gr: 14.0,
energyOnPortion: 52.0,
proteinsOnPortion: 0.3,
fatsOnPortion: 0.2,
carbohydratesOnPortion: 14.0,
);
const pagination = GlossaryPaginationModel(glossariesList: [glossary]);
final json = pagination.toJson();
expect(json.containsKey('data'), isTrue);
expect((json['data'] as List).length, 1);
});
});
group('GlossaryModerationModel', () {
@@ -140,6 +189,28 @@ void main() {
expect(model.glossary.id, 1);
expect(model.glossary.name, 'Apple');
});
test('toJson serializes GlossaryModerationModel correctly', () {
const glossary = GlossaryModel(
id: 1,
name: 'Apple',
grInPortion: 100,
energyOn100Gr: 52.0,
proteinsOn100Gr: 0.3,
fatsOn100Gr: 0.2,
carbohydratesOn100Gr: 14.0,
energyOnPortion: 52.0,
proteinsOnPortion: 0.3,
fatsOnPortion: 0.2,
carbohydratesOnPortion: 14.0,
);
const model = GlossaryModerationModel(glossary: glossary);
final json = model.toJson();
expect(json.containsKey('product_nutritional_value'), isTrue);
});
});
}