231801_test_to_master #1519
|
@ -17,7 +17,7 @@ describe('InvoiceOut refund()', () => {
|
||||||
try {
|
try {
|
||||||
const result = await models.InvoiceOut.refund('T1111111', options);
|
const result = await models.InvoiceOut.refund('T1111111', options);
|
||||||
|
|
||||||
expect(result.length).toEqual(1);
|
expect(result).toBeDefined();
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -22,9 +22,9 @@ describe('Sale refund()', () => {
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const response = await models.Sale.refund(salesIds, servicesIds, false, options);
|
const refundedTicket = await models.Sale.refund(salesIds, servicesIds, false, options);
|
||||||
|
|
||||||
expect(response.length).toBeGreaterThanOrEqual(1);
|
expect(refundedTicket).toBeDefined();
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -33,7 +33,7 @@ describe('Sale refund()', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create a ticket for each unique ticketFk in the sales', async() => {
|
it('should create one ticket for each unique ticketFk in the sales', async() => {
|
||||||
const tx = await models.Sale.beginTransaction({});
|
const tx = await models.Sale.beginTransaction({});
|
||||||
const salesIds = [6, 7];
|
const salesIds = [6, 7];
|
||||||
|
|
||||||
|
@ -41,15 +41,11 @@ describe('Sale refund()', () => {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const createSingleTicket = false;
|
const createSingleTicket = false;
|
||||||
const tickets = await models.Sale.refund(salesIds, servicesIds, createSingleTicket, options);
|
const ticket = await models.Sale.refund(salesIds, servicesIds, createSingleTicket, options);
|
||||||
|
|
||||||
const ticketsIds = tickets.map(ticket => ticket.id);
|
const refundedTicket = await models.Ticket.findOne({
|
||||||
|
|
||||||
const refundedTickets = await models.Ticket.find({
|
|
||||||
where: {
|
where: {
|
||||||
id: {
|
id: ticket.id
|
||||||
inq: ticketsIds
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
|
@ -66,16 +62,12 @@ describe('Sale refund()', () => {
|
||||||
]
|
]
|
||||||
}, options);
|
}, options);
|
||||||
|
|
||||||
const firstRefoundedTicket = refundedTickets[0];
|
const salesLength = refundedTicket.ticketSales().length;
|
||||||
const secondRefoundedTicket = refundedTickets[1];
|
const componentsLength = refundedTicket.ticketSales()[0].components().length;
|
||||||
const salesLength = firstRefoundedTicket.ticketSales().length;
|
|
||||||
const componentsLength = firstRefoundedTicket.ticketSales()[0].components().length;
|
|
||||||
const servicesLength = secondRefoundedTicket.ticketServices().length;
|
|
||||||
|
|
||||||
expect(refundedTickets.length).toEqual(2);
|
expect(refundedTicket).toBeDefined();
|
||||||
expect(salesLength).toEqual(1);
|
expect(salesLength).toEqual(2);
|
||||||
expect(componentsLength).toEqual(4);
|
expect(componentsLength).toEqual(4);
|
||||||
expect(servicesLength).toBeGreaterThanOrEqual(1);
|
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -250,7 +250,7 @@ describe('Ticket Component vnTicketDescriptorMenu', () => {
|
||||||
const params = {
|
const params = {
|
||||||
ticketsIds: [16]
|
ticketsIds: [16]
|
||||||
};
|
};
|
||||||
$httpBackend.expectPOST('Tickets/refund', params).respond([{id: 99}]);
|
$httpBackend.expectPOST('Tickets/refund', params).respond({id: 99});
|
||||||
controller.refund();
|
controller.refund();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
|
|
@ -726,8 +726,7 @@ describe('Ticket', () => {
|
||||||
salesIds: [1, 4],
|
salesIds: [1, 4],
|
||||||
};
|
};
|
||||||
const refundTicket = {id: 99};
|
const refundTicket = {id: 99};
|
||||||
const createdTickets = [refundTicket];
|
$httpBackend.expect('POST', 'Sales/refund', params).respond(200, refundTicket);
|
||||||
$httpBackend.expect('POST', 'Sales/refund', params).respond(200, createdTickets);
|
|
||||||
controller.createRefund();
|
controller.createRefund();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue