181186 - Criar PDV Android para rodar em maquinas P.O.S.
This commit is contained in:
commit
c9983cbad5
204 files changed
+11453
No files matched your search
@@ -0,0 +1,55 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pdv/domain/entities/product.dart';
|
||||
import 'package:pdv/domain/repositories/cart_repository.dart';
|
||||
|
||||
void main() {
|
||||
const product = Product(
|
||||
id: 10,
|
||||
code: 'P10',
|
||||
grade: 'UN',
|
||||
name: 'Caneca',
|
||||
departmentCode: 1,
|
||||
writeDate: '2026-11-12 12:00:00',
|
||||
priceMinorUnits: 1234,
|
||||
);
|
||||
|
||||
test('adiciona, altera quantidade e calcula total em centavos', () {
|
||||
final cart = InMemoryCartRepository();
|
||||
cart.addProduct(product);
|
||||
cart.increaseQuantity(product);
|
||||
|
||||
expect(cart.items.single.quantity, 2);
|
||||
expect(cart.itemCount, 2);
|
||||
expect(cart.totalMinorUnits, 2468);
|
||||
|
||||
cart.decreaseQuantity(product);
|
||||
expect(cart.items.single.quantity, 1);
|
||||
expect(cart.totalMinorUnits, 1234);
|
||||
});
|
||||
|
||||
test('não reduz a quantidade abaixo de um; remover é explícito', () {
|
||||
final cart = InMemoryCartRepository()..addProduct(product);
|
||||
|
||||
cart.decreaseQuantity(product);
|
||||
expect(cart.items.single.quantity, 1);
|
||||
|
||||
cart.removeProduct(product);
|
||||
expect(cart.items, isEmpty);
|
||||
expect(cart.totalMinorUnits, 0);
|
||||
});
|
||||
|
||||
test('não calcula total se algum item não tem preço', () {
|
||||
final cart = InMemoryCartRepository()
|
||||
..addProduct(product)
|
||||
..addProduct(const Product(
|
||||
id: 11,
|
||||
code: 'P11',
|
||||
grade: 'UN',
|
||||
name: 'Item sem preço',
|
||||
departmentCode: 1,
|
||||
writeDate: '',
|
||||
));
|
||||
|
||||
expect(cart.totalMinorUnits, isNull);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user