refactor ticket_sale
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2021-12-01 11:39:48 +01:00
parent 77191b6182
commit 75e32feb16
3 changed files with 6 additions and 8 deletions

View File

@ -11,7 +11,7 @@ module.exports = Self => {
http: {source: 'body'} http: {source: 'body'}
}], }],
returns: { returns: {
type: 'Number', type: 'number',
root: true root: true
}, },
http: { http: {

View File

@ -453,9 +453,8 @@ class Controller extends Section {
const sales = this.selectedValidSales(); const sales = this.selectedValidSales();
if (!sales) return; if (!sales) return;
const params = sales;
const query = `Sales/recalculatePrice`; const query = `Sales/recalculatePrice`;
this.$http.post(query, params).then(() => { this.$http.post(query, sales).then(() => {
this.vnApp.showSuccess(this.$t('Data saved!')); this.vnApp.showSuccess(this.$t('Data saved!'));
this.$.model.refresh(); this.$.model.refresh();
}); });

View File

@ -684,14 +684,13 @@ describe('Ticket', () => {
}); });
describe('calculateSalePrice()', () => { describe('calculateSalePrice()', () => {
it('should make an HTTP post query ', () => { it('should make an HTTP post query', () => {
jest.spyOn(controller.vnApp, 'showSuccess').mockReturnThis(); jest.spyOn(controller.vnApp, 'showSuccess').mockReturnThis();
jest.spyOn(controller.$.model, 'refresh').mockReturnThis(); jest.spyOn(controller.$.model, 'refresh').mockReturnThis();
const selectedSaleOne = controller.sales[0]; controller.sales.forEach(sale => {
const selectedSaleTwo = controller.sales[1]; sale.checked = true;
selectedSaleOne.checked = true; });
selectedSaleTwo.checked = true;
$httpBackend.expect('POST', `Sales/recalculatePrice`).respond(200); $httpBackend.expect('POST', `Sales/recalculatePrice`).respond(200);
controller.calculateSalePrice(); controller.calculateSalePrice();