fix test back

This commit is contained in:
Alexandre Riera 2022-11-16 13:46:16 +01:00
parent 3dd43d21ae
commit e4a6585b6a
3 changed files with 14 additions and 11 deletions

View File

@ -21,3 +21,7 @@ BEGIN
CALL vn.collection_missingTrash(vSaleFk ,vQuantity ,vIsTrash ,vWarehouseFk ,vNewQuantity); CALL vn.collection_missingTrash(vSaleFk ,vQuantity ,vIsTrash ,vWarehouseFk ,vNewQuantity);
END$$ END$$
DELIMITER ; DELIMITER ;
INSERT INTO `salix`.`ACL`
(model, property, accessType, permission, principalType, principalId)
VALUES('Sale', 'missingTrash', 'WRITE', 'ALLOW', 'ROLE', 'employee');

View File

@ -7,23 +7,22 @@ describe('sale missingTrash()', () => {
try { try {
const options = { transaction: tx }; const options = { transaction: tx };
const saleFk = 1; const quantity = 1;
const quantity = 3;
const isTrash = true; const isTrash = true;
const warehouseFk = 1;
const newQuantity = 2;
const ctx = { req: { accessToken: { userId: 9 } } }; const ctx = { req: { accessToken: { userId: 9 } } };
let sale = await models.Sale.findById(saleFk, null, options); const sale = await models.Sale.findOne({fields: ['id','quantity', 'originalQuantity', 'ticketFk']}, options);
expect(sale.quantity).toEqual(5); console.log(sale);
expect(sale.originalQuantity).toBe(null); const ticket = await models.Ticket.findById(sale.ticketFk, {fields: ['warehouseFk']}, options);
console.log(ticket);
const newQuantity = sale.quantity-quantity;
await models.Sale.missingTrash(ctx, saleFk, quantity, isTrash, warehouseFk, newQuantity, options); await models.Sale.missingTrash(ctx, sale.id, quantity, isTrash, ticket.warehouseFk, newQuantity, options);
sale = await models.Sale.findById(saleFk, null, options); const saleAfter = await models.Sale.findById(sale.id, {fields: ['quantity', 'originalQuantity']}, options);
expect(sale.quantity).toEqual(2); expect(saleAfter.quantity).toEqual(newQuantity);
expect(sale.originalQuantity).toBe(5); expect(saleAfter.originalQuantity).toBe(sale.quantity);
await tx.rollback(); await tx.rollback();