fixes before build
This commit is contained in:
@@ -52,6 +52,25 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
test('getLastTripSupermarkets lists unique stores newest first', () async {
|
||||
final repository = memoryRepository();
|
||||
await repository.saveShop(
|
||||
supermarket: 'Jumbo',
|
||||
shoppedAt: DateTime(2026, 8, 1),
|
||||
items: [LineItem(id: '1', name: 'Milk', price: 1.5)],
|
||||
);
|
||||
await repository.saveShop(
|
||||
supermarket: 'Albert Heijn',
|
||||
shoppedAt: DateTime(2026, 8, 12),
|
||||
items: [LineItem(id: '2', name: 'Bread', price: 2)],
|
||||
);
|
||||
|
||||
expect(await repository.getLastTripSupermarkets(), [
|
||||
'Albert Heijn',
|
||||
'Jumbo',
|
||||
]);
|
||||
});
|
||||
|
||||
test('deleting all products leaves shopping trips in place', () async {
|
||||
final repository = memoryRepository();
|
||||
await repository.saveShop(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:receipity/models/supermarket.dart';
|
||||
import 'package:receipity/utils/supermarkets.dart';
|
||||
|
||||
void main() {
|
||||
@@ -20,4 +21,32 @@ void main() {
|
||||
test('returns null when no supermarket is present', () {
|
||||
expect(detectSupermarket('Milk 1.50\nBread 2.00'), isNull);
|
||||
});
|
||||
|
||||
test('sortStoresByLastTrip puts the latest trip store first', () {
|
||||
const jumbo = Supermarket(id: 1, name: 'Jumbo', colorValue: 1, sortOrder: 0);
|
||||
const lidl = Supermarket(id: 2, name: 'Lidl', colorValue: 2, sortOrder: 1);
|
||||
const ah = Supermarket(
|
||||
id: 3,
|
||||
name: 'Albert Heijn',
|
||||
colorValue: 3,
|
||||
sortOrder: 2,
|
||||
);
|
||||
|
||||
final afterJumbo = sortStoresByLastTrip([jumbo, lidl, ah], ['Jumbo']);
|
||||
expect(afterJumbo.map((store) => store.name), [
|
||||
'Jumbo',
|
||||
'Lidl',
|
||||
'Albert Heijn',
|
||||
]);
|
||||
|
||||
final afterAh = sortStoresByLastTrip(
|
||||
[jumbo, lidl, ah],
|
||||
['Albert Heijn', 'Jumbo'],
|
||||
);
|
||||
expect(afterAh.map((store) => store.name), [
|
||||
'Albert Heijn',
|
||||
'Jumbo',
|
||||
'Lidl',
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user