test(item_fixedPrice): front recalculateRate2
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2022-12-19 15:06:59 +01:00
parent f82870bec6
commit 5d2b69d063
3 changed files with 23 additions and 3 deletions

View File

@ -11,7 +11,7 @@ module.exports = Self => {
},
{
arg: 'rate3',
type: 'number',
type: 'object',
description: `The price rate 3`,
required: true
}
@ -29,6 +29,6 @@ module.exports = Self => {
Self.getRate2 = async(fixedPriceId, rate3) => {
const [result] = await Self.rawSql(`SELECT vn.priceFixed_getRate2(?, ?) as rate2`,
[fixedPriceId, rate3]);
return result.rate2;
return result;
};
};

View File

@ -124,7 +124,7 @@ export default class Controller extends Section {
};
this.$http.get(query, {params})
.then(res => {
const rate2 = res.data;
const rate2 = res.data.rate2;
if (rate2) {
price.rate2 = rate2;
this.upsertPrice(price);

View File

@ -85,5 +85,25 @@ describe('fixed price', () => {
expect(controller.$.model.remove).toHaveBeenCalled();
});
});
describe('recalculateRate2()', () => {
it(`should rate2 recalculate`, () => {
jest.spyOn(controller.vnApp, 'showSuccess');
const price = {
id: 1,
itemFk: 1,
rate2: 2,
rate3: 2
};
const response = {rate2: 1};
controller.recalculateRate2(price);
const query = `FixedPrices/getRate2?fixedPriceId=${price.id}&rate3=${price.rate3}`;
$httpBackend.expectGET(query).respond(response);
$httpBackend.flush();
expect(price.rate2).toEqual(response.rate2);
});
});
});
});