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

36 lines
1016 B
Dart
Raw Permalink 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:cookit/src/recipes/ingredients_text.dart';
import 'package:cookit/src/recipes/models/recipe.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:intl/date_symbol_data_local.dart';
import '../support/fixtures.dart';
void main() {
setUpAll(() => initializeDateFormatting('de'));
String label(String key) => {'gram': 'g', 'tablespoon': 'EL'}[key]!;
test('one Ingredient Line per line, groups separated by an empty line', () {
expect(
ingredientsAsText(recipe().ingredientGroups, label),
'300 g Mehl\n'
'2–3 EL Olivenöl (gutes)\n'
'\n'
'Rosmarin',
);
});
test('scaled amounts and empty groups', () {
final groups = [
const IngredientGroup(lines: []),
const IngredientGroup(lines: [IngredientLine(amount: 1, name: 'Ei')]),
];
expect(
ingredientsAsText([
for (final g in groups) IngredientGroup(lines: [for (final l in g.lines) l.scaled(1.5)]),
], label),
'1½ Ei',
);
});
}