feat: alphabet list, change Layout etc
This commit is contained in:
@@ -319,5 +319,64 @@ void main() {
|
||||
expect(product!.stockQuantity, 0);
|
||||
});
|
||||
});
|
||||
|
||||
group('infinite stock', () {
|
||||
setUp(() async {
|
||||
await database
|
||||
.into(database.products)
|
||||
.insert(
|
||||
ProductsCompanion.insert(
|
||||
id: 'water',
|
||||
name: 'Water',
|
||||
category: 'Drinks',
|
||||
stockQuantity: 0,
|
||||
lowStockThreshold: 0,
|
||||
infiniteStock: const Value(true),
|
||||
priceInCents: 100,
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
test('sells without stock and leaves the count alone', () async {
|
||||
await service.decreaseStock('water', 5);
|
||||
await service.increaseStock('water', 2);
|
||||
|
||||
final product = await service.getProductById('water');
|
||||
expect(product!.stockQuantity, 0);
|
||||
expect(product.infiniteStock, true);
|
||||
expect(product.isOutOfStock, false);
|
||||
expect(product.isLowStock, false);
|
||||
});
|
||||
|
||||
test('still reports a missing product', () async {
|
||||
await expectLater(
|
||||
service.increaseStock('nonexistent', 1),
|
||||
throwsA(isA<ProductNotFoundException>()),
|
||||
);
|
||||
});
|
||||
|
||||
test('is saved by create and update', () async {
|
||||
await service.createProduct(
|
||||
name: 'Tap water',
|
||||
category: 'Drinks',
|
||||
stockQuantity: 0,
|
||||
lowStockThreshold: 0,
|
||||
infiniteStock: true,
|
||||
priceInCents: 0,
|
||||
imagePath: null,
|
||||
);
|
||||
final created = (await service.getProducts()).firstWhere(
|
||||
(product) => product.name == 'Tap water',
|
||||
);
|
||||
expect(created.infiniteStock, true);
|
||||
|
||||
await service.updateProduct(
|
||||
created.copyWith(infiniteStock: false, stockQuantity: 4),
|
||||
);
|
||||
final updated = await service.getProductById(created.id);
|
||||
expect(updated!.infiniteStock, false);
|
||||
expect(updated.stockQuantity, 4);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user