test(item_fixedPrice): front recalculateRate2
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
f82870bec6
commit
5d2b69d063
|
@ -11,7 +11,7 @@ module.exports = Self => {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
arg: 'rate3',
|
arg: 'rate3',
|
||||||
type: 'number',
|
type: 'object',
|
||||||
description: `The price rate 3`,
|
description: `The price rate 3`,
|
||||||
required: true
|
required: true
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,6 @@ module.exports = Self => {
|
||||||
Self.getRate2 = async(fixedPriceId, rate3) => {
|
Self.getRate2 = async(fixedPriceId, rate3) => {
|
||||||
const [result] = await Self.rawSql(`SELECT vn.priceFixed_getRate2(?, ?) as rate2`,
|
const [result] = await Self.rawSql(`SELECT vn.priceFixed_getRate2(?, ?) as rate2`,
|
||||||
[fixedPriceId, rate3]);
|
[fixedPriceId, rate3]);
|
||||||
return result.rate2;
|
return result;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -124,7 +124,7 @@ export default class Controller extends Section {
|
||||||
};
|
};
|
||||||
this.$http.get(query, {params})
|
this.$http.get(query, {params})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
const rate2 = res.data;
|
const rate2 = res.data.rate2;
|
||||||
if (rate2) {
|
if (rate2) {
|
||||||
price.rate2 = rate2;
|
price.rate2 = rate2;
|
||||||
this.upsertPrice(price);
|
this.upsertPrice(price);
|
||||||
|
|
|
@ -85,5 +85,25 @@ describe('fixed price', () => {
|
||||||
expect(controller.$.model.remove).toHaveBeenCalled();
|
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);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue