231801_test_to_master #1519

Merged
alexm merged 490 commits from 231801_test_to_master into master 2023-05-12 06:29:59 +00:00
4 changed files with 13 additions and 22 deletions
Showing only changes of commit 9b432bac85 - Show all commits

View File

@ -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) {

View File

@ -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) {

View File

@ -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();

View File

@ -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();