Files
CookIT/test/recipes/ingredients_text_test.dart
T

35 lines
1016 B
Dart
Raw Normal View History

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',
);
});
}