import 'package:flutter_test/flutter_test.dart'; import 'package:kooltab2/models/product.dart'; void main() { group('Product', () { group('isLowStock', () { test('returns true when stock equals threshold', () { const product = Product( id: '1', name: 'Test', category: 'Drinks', stockQuantity: 5, lowStockThreshold: 5, priceInCents: 100, ); expect(product.isLowStock, true); }); test('returns true when stock is below threshold', () { const product = Product( id: '1', name: 'Test', category: 'Drinks', stockQuantity: 3, lowStockThreshold: 5, priceInCents: 100, ); expect(product.isLowStock, true); }); test('returns false when stock is above threshold', () { const product = Product( id: '1', name: 'Test', category: 'Drinks', stockQuantity: 10, lowStockThreshold: 5, priceInCents: 100, ); expect(product.isLowStock, false); }); }); group('formattedPrice', () { test('formats price with euro symbol and 2 decimals', () { const product = Product( id: '1', name: 'Test', category: 'Drinks', stockQuantity: 10, lowStockThreshold: 5, priceInCents: 1234, ); expect(product.formattedPrice, '€12.34'); }); test('formats zero price correctly', () { const product = Product( id: '1', name: 'Test', category: 'Drinks', stockQuantity: 10, lowStockThreshold: 5, priceInCents: 0, ); expect(product.formattedPrice, '€0.00'); }); test('formats whole euros correctly', () { const product = Product( id: '1', name: 'Test', category: 'Drinks', stockQuantity: 10, lowStockThreshold: 5, priceInCents: 500, ); expect(product.formattedPrice, '€5.00'); }); }); group('copyWith', () { test('creates copy with updated fields', () { const original = Product( id: '1', name: 'Original', category: 'Drinks', stockQuantity: 10, lowStockThreshold: 5, priceInCents: 100, ); final copy = original.copyWith(name: 'Updated', stockQuantity: 20); expect(copy.name, 'Updated'); expect(copy.stockQuantity, 20); expect(copy.id, '1'); expect(copy.category, 'Drinks'); }); test('preserves original values when not specified', () { const original = Product( id: '1', name: 'Test', category: 'Food', stockQuantity: 15, lowStockThreshold: 3, priceInCents: 750, imagePath: '/path/to/image.jpg', active: false, ); final copy = original.copyWith(); expect(copy.id, '1'); expect(copy.name, 'Test'); expect(copy.category, 'Food'); expect(copy.stockQuantity, 15); expect(copy.lowStockThreshold, 3); expect(copy.priceInCents, 750); expect(copy.imagePath, '/path/to/image.jpg'); expect(copy.active, false); }); }); }); }