Files
CookIT/test/recipes/recipe_model_test.dart
2026-10-28 22:55:09 +01:00

19 lines
806 B
Dart

import 'package:cookit/src/recipes/models/recipe.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
test('unit keys round-trip through JSON, built-in or own', () {
for (final key in ['gram', 'bunch', 'own-1234']) {
final line = IngredientLine.fromJson(IngredientLine(amount: 1, unitKey: key, name: 'x').toJson());
expect(line.unitKey, key);
}
});
test('scaled multiplies amount and range, keeps the rest', () {
const line = IngredientLine(amount: 2, amountMax: 3, unitKey: 'tablespoon', name: 'Öl', remark: 'gutes');
final half = line.scaled(0.5);
expect((half.amount, half.amountMax, half.unitKey, half.name, half.remark), (1, 1.5, 'tablespoon', 'Öl', 'gutes'));
expect(const IngredientLine(name: 'Salz').scaled(2).amount, isNull);
});
}