fix test back
This commit is contained in:
parent
3dd43d21ae
commit
e4a6585b6a
|
@ -21,3 +21,7 @@ BEGIN
|
|||
CALL vn.collection_missingTrash(vSaleFk ,vQuantity ,vIsTrash ,vWarehouseFk ,vNewQuantity);
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
||||
INSERT INTO `salix`.`ACL`
|
||||
(model, property, accessType, permission, principalType, principalId)
|
||||
VALUES('Sale', 'missingTrash', 'WRITE', 'ALLOW', 'ROLE', 'employee');
|
||||
|
|
|
@ -7,23 +7,22 @@ describe('sale missingTrash()', () => {
|
|||
try {
|
||||
const options = { transaction: tx };
|
||||
|
||||
const saleFk = 1;
|
||||
const quantity = 3;
|
||||
const quantity = 1;
|
||||
const isTrash = true;
|
||||
const warehouseFk = 1;
|
||||
const newQuantity = 2;
|
||||
|
||||
const ctx = { req: { accessToken: { userId: 9 } } };
|
||||
|
||||
let sale = await models.Sale.findById(saleFk, null, options);
|
||||
expect(sale.quantity).toEqual(5);
|
||||
expect(sale.originalQuantity).toBe(null);
|
||||
const sale = await models.Sale.findOne({fields: ['id','quantity', 'originalQuantity', 'ticketFk']}, options);
|
||||
console.log(sale);
|
||||
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);
|
||||
expect(sale.quantity).toEqual(2);
|
||||
expect(sale.originalQuantity).toBe(5);
|
||||
const saleAfter = await models.Sale.findById(sale.id, {fields: ['quantity', 'originalQuantity']}, options);
|
||||
expect(saleAfter.quantity).toEqual(newQuantity);
|
||||
expect(saleAfter.originalQuantity).toBe(sale.quantity);
|
||||
|
||||
await tx.rollback();
|
||||
|
||||
|
|
Loading…
Reference in New Issue