// sugar.dart against the dashboard's plugins/food/sugar.py: the same kinds for the same foods (the table // below is sugar.kind's output — regenerate it there when the rules change) and the same folding. import 'package:dash_app/health/sugar.dart'; import 'package:flutter_test/flutter_test.dart'; // name, category, source, nova, labels, sugarsIn, dairy → kind const cases = <(String, String, String, int?, String, String?, int?, String)>[ ('Figs, dried, uncooked', 'Fruits and Fruit Juices', 'sr_legacy', null, '', null, null, 'natural'), ('Orange juice, raw', 'Fruits and Fruit Juices', 'sr_legacy', null, '', null, null, 'added'), ('Beverages, carbonated, cola, regular', 'Beverages', 'sr_legacy', null, '', null, null, 'added'), ('Alcoholic beverage, wine, table, red', 'Beverages', 'sr_legacy', null, '', null, null, 'added'), ('Yogurt, plain, whole milk', 'Dairy and Egg Products', 'sr_legacy', null, '', null, null, 'dairy'), ('Yogurt, fruit, low fat', 'Dairy and Egg Products', 'sr_legacy', null, '', null, null, 'dairy'), ('Zahăr brun', '', '', null, '', null, null, 'added'), ('Smântână 20%', '', '', null, '', null, null, 'dairy'), ('Sušienky s čokoládou', '', '', null, '', null, null, 'added'), ('Túró Rudi', '', '', null, '', null, null, 'dairy'), ('Apfelsaft naturtrüb', '', '', null, '', null, null, 'added'), ('Mandelmilch ungesüßt', '', '', null, '', null, null, 'natural'), ('Lapte de migdale', '', '', null, '', null, null, 'natural'), ('Iaurt grecesc', '', '', null, '', null, null, 'dairy'), ('Gemüsebrühe', '', '', null, '', null, null, 'natural'), ('Ciocolată neagră 70%', '', '', null, '', null, null, 'added'), ('Tomates pelées', 'Tomatoes', 'off', 3, '', '', 0, 'natural'), ('Biscuiți cu unt', 'Biscuits', 'off', 4, '', 'sugar, glucose syrup', 0, 'added'), ('Jogurt jahodový', 'Yogurts', 'off', 3, '', 'sugar', 1, 'dairy'), ('Jogurt biely', 'Yogurts', 'off', 3, '', '', 1, 'dairy'), ('Müsli ohne Zuckerzusatz', 'Cereals', 'off', 3, 'no added sugar', null, 0, 'natural'), ('Bio Haferflocken', '', 'off', 1, '', null, null, 'natural'), ('Sardine fillets', '', 'off', null, '', null, null, 'added'), ('Kefír', '', 'off', null, '', null, null, 'dairy'), ('Plant drink, oat', '', 'off', 4, '', '', 0, 'natural'), ('Cereals, oats, regular and quick, not fortified, dry', 'Breakfast Cereals', 'sr_legacy', null, '', null, null, 'natural'), ('Cereals ready-to-eat, POST, HONEY BUNCHES OF OATS, honey roasted', 'Breakfast Cereals', 'sr_legacy', null, '', null, null, 'added'), ('Wine, table, red', 'Wine', 'survey', null, '', null, null, 'added'), ]; void main() { test('kinds match sugar.py', () { for (final (name, category, source, nova, labels, sugarsIn, dairy, want) in cases) { expect(sugarKind(name, category: category, source: source, nova: nova, labels: labels, sugarsIn: sugarsIn, dairy: dairy), want, reason: name); } }); test('folding matches sugar.fold', () { const want = {'Zahăr': 'zahar', 'ŠŤAVA': 'stava', 'Groß': 'gross', 'Łódź': 'lodz', 'smântână': 'smantana', 'Crème brûlée': 'creme brulee', 'tvaroh': 'tvaroh'}; want.forEach((w, f) => expect(fold(w), f, reason: w)); }); }