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 {
const result = await models.InvoiceOut.refund('T1111111', options);
expect(result.length).toEqual(1);
expect(result).toBeDefined();
await tx.rollback();
} catch (e) {

View File

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

View File

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

View File

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