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