salix/back/methods/collection/spec/setSaleQuantity.spec.js

24 lines
675 B
JavaScript

const models = require('vn-loopback/server/server').models;
describe('setSaleQuantity()', () => {
it('should change quantity sale', async() => {
const saleId = 30;
const newQuantity = 10;
const ctx = {
args: {
saleId: saleId,
quantity: newQuantity
}
};
const originalSale = await models.Sale.findById(saleId);
await models.Collection.setSaleQuantity(ctx);
const updateSale = await models.Sale.findById(saleId);
expect(updateSale.quantity).toBeLessThan(originalSale.quantity);
expect(updateSale.quantity).toEqual(newQuantity);
});
});