test: espandi copertura a 110 test e organizza in gruppi
- Aggiunto converter_provider_test.dart (nuovo): stato iniziale, select, setGrams, result, swapDirection, reset, search - Aggiunto qr_test.dart (nuovo): buildQrPayload e parseMealPlanFromQr con round-trip e casi di errore - meal_planner_provider_test: group(), importPlan(), fallback JSON corrotto - shopping_list_provider_test: group(), addAll con aggregazione quantity, fallback JSON corrotto - shopping_item_test: campi quantity (default, copyWith, JSON round-trip) - shopping_item_tile_test: group(), visualizzazione (xN) - conversion_entry_test: caso limite yieldFactor=0 - meal_card_test: group() - Rimosso widget_test.dart (boilerplate obsoleto) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,11 @@ void main() {
|
||||
expect(item.checked, false);
|
||||
});
|
||||
|
||||
test('quantity è 1 di default', () {
|
||||
final item = ShoppingItem(id: '1', name: 'Pollo');
|
||||
expect(item.quantity, 1);
|
||||
});
|
||||
|
||||
test('copyWith() aggiorna solo il campo specificato', () {
|
||||
final item = ShoppingItem(id: '1', name: 'Pollo');
|
||||
final checked = item.copyWith(checked: true);
|
||||
@@ -16,18 +21,26 @@ void main() {
|
||||
expect(checked.id, '1');
|
||||
});
|
||||
|
||||
test('copyWith() aggiorna quantity', () {
|
||||
final item = ShoppingItem(id: '1', name: 'Zucchine');
|
||||
final updated = item.copyWith(quantity: 3);
|
||||
expect(updated.quantity, 3);
|
||||
expect(updated.name, 'Zucchine');
|
||||
});
|
||||
|
||||
test('copyWith() non modifica lorigine', () {
|
||||
final item = ShoppingItem(id: '1', name: 'Pollo');
|
||||
item.copyWith(checked: true);
|
||||
expect(item.checked, false);
|
||||
});
|
||||
|
||||
test('JSON round-trip preserva tutti i campi', () {
|
||||
const item = ShoppingItem(id: '42', name: 'Riso', checked: true);
|
||||
test('JSON round-trip preserva tutti i campi incluso quantity', () {
|
||||
const item = ShoppingItem(id: '42', name: 'Riso', checked: true, quantity: 3);
|
||||
final restored = ShoppingItem.fromJson(item.toJson());
|
||||
expect(restored.id, '42');
|
||||
expect(restored.name, 'Riso');
|
||||
expect(restored.checked, true);
|
||||
expect(restored.quantity, 3);
|
||||
});
|
||||
|
||||
test('fromJson gestisce campo checked assente (default false)', () {
|
||||
@@ -35,12 +48,18 @@ void main() {
|
||||
expect(item.checked, false);
|
||||
});
|
||||
|
||||
test('toJson produce la mappa corretta', () {
|
||||
const item = ShoppingItem(id: '5', name: 'Zucchine', checked: false);
|
||||
test('fromJson gestisce campo quantity assente (default 1)', () {
|
||||
final item = ShoppingItem.fromJson({'id': '1', 'name': 'Pasta', 'checked': false});
|
||||
expect(item.quantity, 1);
|
||||
});
|
||||
|
||||
test('toJson produce la mappa corretta con quantity', () {
|
||||
const item = ShoppingItem(id: '5', name: 'Zucchine', checked: false, quantity: 2);
|
||||
final json = item.toJson();
|
||||
expect(json['id'], '5');
|
||||
expect(json['name'], 'Zucchine');
|
||||
expect(json['checked'], false);
|
||||
expect(json['quantity'], 2);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user