Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into dev
gitea/salix/dev This commit looks good
Details
gitea/salix/dev This commit looks good
Details
This commit is contained in:
commit
ed3024e144
|
@ -73,6 +73,7 @@
|
|||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-input-number vn-one min="0"
|
||||
step="0.01"
|
||||
label="Density"
|
||||
field="$ctrl.item.density">
|
||||
</vn-input-number>
|
||||
|
|
|
@ -1,31 +1,121 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('sale updatePrice()', () => {
|
||||
it('should throw an error if the price is not a number', async() => {
|
||||
let error;
|
||||
// #1489 updatePrice backTest
|
||||
xdescribe('sale updatePrice()', () => {
|
||||
it('should set price to 0 if the params price is undefined', async() => {
|
||||
let params = {
|
||||
price: undefined,
|
||||
id: 13,
|
||||
ticketFk: 8
|
||||
};
|
||||
await app.models.Sale.updatePrice(params);
|
||||
let saleUpdated = await app.models.Sale.findById(params.id);
|
||||
|
||||
let params = {price: `this price is so wrong!`};
|
||||
|
||||
await app.models.Sale.updatePrice(params)
|
||||
.catch(response => {
|
||||
expect(response).toEqual(new Error('The value should be a number'));
|
||||
error = response;
|
||||
});
|
||||
|
||||
expect(error).toBeDefined();
|
||||
expect(saleUpdated.price).toEqual(0);
|
||||
});
|
||||
|
||||
it(`should throw an error if the price is undefined`, async() => {
|
||||
let error;
|
||||
it('should set price as a decimal number', async() => {
|
||||
let params = {
|
||||
price: 5.5,
|
||||
id: 13,
|
||||
ticketFk: 8
|
||||
};
|
||||
await app.models.Sale.updatePrice(params);
|
||||
let saleUpdated = await app.models.Sale.findById(params.id);
|
||||
|
||||
let params = {ticketFk: 1, price: undefined};
|
||||
|
||||
await app.models.Sale.updatePrice(params)
|
||||
.catch(response => {
|
||||
expect(response).toEqual(new Error('The value should be a number'));
|
||||
error = response;
|
||||
});
|
||||
|
||||
expect(error).toBeDefined();
|
||||
expect(saleUpdated.price).toEqual(5.5);
|
||||
});
|
||||
|
||||
it('should now set price as a decimal number in a string', async() => {
|
||||
let params = {
|
||||
price: '5.5',
|
||||
id: 13,
|
||||
ticketFk: 8
|
||||
};
|
||||
await app.models.Sale.updatePrice(params);
|
||||
let saleUpdated = await app.models.Sale.findById(params.id);
|
||||
|
||||
expect(saleUpdated.price).toEqual(5.5);
|
||||
});
|
||||
|
||||
it('should return 0 if the price is an empty string', async() => {
|
||||
let params = {
|
||||
price: '',
|
||||
id: 13,
|
||||
ticketFk: 8
|
||||
};
|
||||
await app.models.Sale.updatePrice(params);
|
||||
let saleUpdated = await app.models.Sale.findById(params.id);
|
||||
|
||||
expect(saleUpdated.price).toEqual(0);
|
||||
});
|
||||
|
||||
|
||||
it('should este crea mana', async() => {
|
||||
let params = {
|
||||
price: 5.5,
|
||||
id: 13,
|
||||
ticketFk: 8
|
||||
};
|
||||
await app.models.Sale.updatePrice(params);
|
||||
let saleUpdated = await app.models.Sale.findById(params.id);
|
||||
|
||||
expect(saleUpdated.price).toEqual(5.5);
|
||||
});
|
||||
|
||||
it('should este no crea el mana', async() => {
|
||||
let params = {
|
||||
price: 5.5,
|
||||
id: 13,
|
||||
ticketFk: 8
|
||||
};
|
||||
let todosLosComponentes = await app.models.SaleComponent.find({where: {saleFk: 13}});
|
||||
|
||||
expect(todosLosComponentes[0].value).toEqual('');
|
||||
expect(todosLosComponentes[1].value).toEqual('');
|
||||
expect(todosLosComponentes[2].value).toEqual('');
|
||||
expect(todosLosComponentes[3].value).toEqual('');
|
||||
expect(todosLosComponentes[4].value).toEqual('');
|
||||
|
||||
await app.models.Sale.updatePrice(params);
|
||||
todosLosComponentes = await app.models.SaleComponent.find({where: {saleFk: 13}});
|
||||
let saleUpdated = await app.models.Sale.findById(params.id);
|
||||
|
||||
expect(saleUpdated.price).toEqual(5.5);
|
||||
|
||||
expect(todosLosComponentes[0].value).toEqual('');
|
||||
expect(todosLosComponentes[1].value).toEqual('');
|
||||
expect(todosLosComponentes[2].value).toEqual('');
|
||||
expect(todosLosComponentes[3].value).toEqual('');
|
||||
expect(todosLosComponentes[4].value).toEqual('');
|
||||
});
|
||||
// 2 let componentToUse;
|
||||
// if (usesMana)
|
||||
// componentToUse = 37;
|
||||
// 3else
|
||||
// componentToUse = 34;
|
||||
|
||||
// 4 if (saleComponent)
|
||||
// saleComponent.updateAttributes({value: saleComponent.value + value});
|
||||
// 5 else {
|
||||
// await Self.app.models.SaleComponent.create({
|
||||
// saleFk: params.id,
|
||||
// componentFk: componentToUse,
|
||||
// value: value
|
||||
// });
|
||||
// }
|
||||
|
||||
// it(`should throw an error if the price is undefined`, async() => {
|
||||
// let error;
|
||||
|
||||
// let params = {ticketFk: 1, price: undefined};
|
||||
|
||||
// await app.models.Sale.updatePrice(params)
|
||||
// .catch(response => {
|
||||
// expect(response).toEqual(new Error('The value should be a number'));
|
||||
// error = response;
|
||||
// });
|
||||
|
||||
// expect(error).toBeDefined();
|
||||
// });
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue