refactor: add frontTest
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
5e35783a38
commit
7abceb8564
|
@ -117,35 +117,37 @@ class Controller extends Section {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async refundInvoiceOut() {
|
refundInvoiceOut() {
|
||||||
let filter = {
|
let filter = {
|
||||||
where: {refFk: this.invoiceOut.ref}
|
where: {refFk: this.invoiceOut.ref}
|
||||||
};
|
};
|
||||||
await this.$http.get('Tickets', {filter})
|
this.$http.get('Tickets', {filter})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
this.tickets = res.data;
|
this.tickets = res.data;
|
||||||
this.ticketsIds = [];
|
this.ticketsIds = [];
|
||||||
for (let ticket of this.tickets)
|
for (let ticket of this.tickets)
|
||||||
this.ticketsIds.push(ticket.id);
|
this.ticketsIds.push(ticket.id);
|
||||||
|
|
||||||
|
filter = {
|
||||||
|
where: {ticketFk: {inq: this.ticketsIds}}
|
||||||
|
};
|
||||||
|
this.$http.get('Sales', {filter})
|
||||||
|
.then(res => {
|
||||||
|
this.sales = res.data;
|
||||||
|
this.$http.get('TicketServices', {filter})
|
||||||
|
.then(res => {
|
||||||
|
this.services = res.data;
|
||||||
|
const params = {
|
||||||
|
sales: this.sales,
|
||||||
|
services: this.services
|
||||||
|
};
|
||||||
|
const query = `Sales/refund`;
|
||||||
|
return this.$http.post(query, params).then(res => {
|
||||||
|
this.$state.go('ticket.card.sale', {id: res.data});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
filter = {
|
|
||||||
where: {ticketFk: {inq: this.ticketsIds}}
|
|
||||||
};
|
|
||||||
await this.$http.get('Sales', {filter})
|
|
||||||
.then(res => this.sales = res.data);
|
|
||||||
|
|
||||||
await this.$http.get('TicketServices', {filter})
|
|
||||||
.then(res => this.services = res.data);
|
|
||||||
|
|
||||||
const params = {
|
|
||||||
sales: this.sales,
|
|
||||||
services: this.services
|
|
||||||
};
|
|
||||||
const query = `Sales/refund`;
|
|
||||||
return this.$http.post(query, params).then(res => {
|
|
||||||
this.$state.go('ticket.card.sale', {id: res.data});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,4 +122,33 @@ describe('vnInvoiceOutDescriptorMenu', () => {
|
||||||
expect(controller.vnApp.showMessage).toHaveBeenCalled();
|
expect(controller.vnApp.showMessage).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('refundInvoiceOut()', () => {
|
||||||
|
it('should make a query and go to ticket.card.sale', () => {
|
||||||
|
controller.$state.go = jest.fn();
|
||||||
|
|
||||||
|
const invoiceOut = {
|
||||||
|
id: 1,
|
||||||
|
ref: 'T1111111'
|
||||||
|
};
|
||||||
|
controller.invoiceOut = invoiceOut;
|
||||||
|
const tickets = [{id: 1}];
|
||||||
|
const sales = [{id: 1}];
|
||||||
|
const services = [{id: 2}];
|
||||||
|
|
||||||
|
$httpBackend.expectGET(`Tickets`).respond(tickets);
|
||||||
|
$httpBackend.expectGET(`Sales`).respond(sales);
|
||||||
|
$httpBackend.expectGET(`TicketServices`).respond(services);
|
||||||
|
|
||||||
|
const expectedParams = {
|
||||||
|
sales: sales,
|
||||||
|
services: services
|
||||||
|
};
|
||||||
|
$httpBackend.expectPOST(`Sales/refund`, expectedParams).respond();
|
||||||
|
controller.refundInvoiceOut();
|
||||||
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.sale', {id: undefined});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -273,24 +273,26 @@ class Controller extends Section {
|
||||||
.then(() => this.vnApp.showSuccess(this.$t('Data saved!')));
|
.then(() => this.vnApp.showSuccess(this.$t('Data saved!')));
|
||||||
}
|
}
|
||||||
|
|
||||||
async refund() {
|
refund() {
|
||||||
const filter = {
|
const filter = {
|
||||||
where: {ticketFk: this.id}
|
where: {ticketFk: this.id}
|
||||||
};
|
};
|
||||||
await this.$http.get('Sales', {filter})
|
this.$http.get('Sales', {filter})
|
||||||
.then(res => this.sales = res.data);
|
.then(res => {
|
||||||
|
this.sales = res.data;
|
||||||
await this.$http.get('TicketServices', {filter})
|
this.$http.get('TicketServices', {filter})
|
||||||
.then(res => this.services = res.data);
|
.then(res => {
|
||||||
|
this.services = res.data;
|
||||||
const params = {
|
const params = {
|
||||||
sales: this.sales,
|
sales: this.sales,
|
||||||
services: this.services
|
services: this.services
|
||||||
};
|
};
|
||||||
const query = `Sales/refund`;
|
const query = `Sales/refund`;
|
||||||
return this.$http.post(query, params).then(res => {
|
return this.$http.post(query, params).then(res => {
|
||||||
this.$state.go('ticket.card.sale', {id: res.data});
|
this.$state.go('ticket.card.sale', {id: res.data});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -264,51 +264,14 @@ describe('Ticket Component vnTicketDescriptorMenu', () => {
|
||||||
|
|
||||||
describe('refund()', () => {
|
describe('refund()', () => {
|
||||||
it('should make a query and go to ticket.card.sale', () => {
|
it('should make a query and go to ticket.card.sale', () => {
|
||||||
jest.spyOn(controller.$state, 'go').mockReturnValue();
|
controller.$state.go = jest.fn();
|
||||||
|
|
||||||
const sales = [{
|
controller._id = ticket.id;
|
||||||
id: 13,
|
const sales = [{id: 1}];
|
||||||
concept: 'Melee weapon combat fist 15cm',
|
const services = [{id: 2}];
|
||||||
quantity: 10,
|
|
||||||
price: 7.08,
|
|
||||||
discount: 0,
|
|
||||||
reserved: false,
|
|
||||||
isPicked: 0,
|
|
||||||
created: '2022-04-21T22:00:00.000Z',
|
|
||||||
itemFk: 2,
|
|
||||||
ticketFk: 8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 14,
|
|
||||||
concept: 'Ranged weapon longbow 2m',
|
|
||||||
quantity: 2,
|
|
||||||
price: 103.49,
|
|
||||||
discount: 0,
|
|
||||||
reserved: false,
|
|
||||||
isPicked: 0,
|
|
||||||
created: '2022-04-21T22:00:00.000Z',
|
|
||||||
itemFk: 1,
|
|
||||||
ticketFk: 8
|
|
||||||
}];
|
|
||||||
|
|
||||||
const services = [{
|
$httpBackend.expectGET(`Sales`).respond(sales);
|
||||||
id: 5,
|
$httpBackend.expectGET(`TicketServices`).respond(services);
|
||||||
ticketFk: 8,
|
|
||||||
description: 'Documentos',
|
|
||||||
quantity: 1,
|
|
||||||
price: 2,
|
|
||||||
taxClassFk: 1,
|
|
||||||
ticketServiceTypeFk: 1
|
|
||||||
}];
|
|
||||||
|
|
||||||
const filter = {
|
|
||||||
where: {ticketFk: ticket.id}
|
|
||||||
};
|
|
||||||
const serializedParams = $httpParamSerializer({filter});
|
|
||||||
console.log(serializedParams);
|
|
||||||
|
|
||||||
$httpBackend.expect('GET', `Sales?${serializedParams}`).respond();
|
|
||||||
$httpBackend.expectGET(`TicketServices?filter=${serializedParams}`).respond();
|
|
||||||
|
|
||||||
const expectedParams = {
|
const expectedParams = {
|
||||||
sales: sales,
|
sales: sales,
|
||||||
|
@ -318,7 +281,7 @@ describe('Ticket Component vnTicketDescriptorMenu', () => {
|
||||||
controller.refund();
|
controller.refund();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.sale', {id: {ticketId: ticket.id}});
|
expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.sale', {id: undefined});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue