fix: test back
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Vicent Llopis 2023-02-16 10:45:13 +01:00
parent 3096738b84
commit b5d2d53435
3 changed files with 8 additions and 7 deletions

View File

@ -17,7 +17,7 @@ describe('InvoiceOut refund()', () => {
try {
const result = await models.InvoiceOut.refund('T1111111', options);
expect(result.length).toEqual(2);
expect(result.length).toEqual(1);
await tx.rollback();
} catch (e) {

View File

@ -97,7 +97,7 @@ module.exports = Self => {
}
for (const sale of sales) {
const refundTicketId = await getTicketRefundId(createSingleTicket, sale.ticketFk, refundTickets);
const refundTicketId = await getTicketRefundId(createSingleTicket, sale.ticketFk, refundTickets, mappedTickets);
const createdSale = await models.Sale.create({
ticketFk: refundTicketId,
@ -122,7 +122,7 @@ module.exports = Self => {
const services = await models.TicketService.find(servicesFilter, myOptions);
for (const service of services) {
const refundTicketId = await getTicketRefundId(createSingleTicket, service.ticketFk, refundTickets);
const refundTicketId = await getTicketRefundId(createSingleTicket, service.ticketFk, refundTickets, mappedTickets);
await models.TicketService.create({
description: service.description,
@ -180,7 +180,7 @@ module.exports = Self => {
}, myOptions);
}
async function getTicketRefundId(createSingleTicket, ticketId, refundTickets) {
async function getTicketRefundId(createSingleTicket, ticketId, refundTickets, mappedTickets) {
if (createSingleTicket) {
const [firstRefundTicket] = refundTickets;
return firstRefundTicket.id;

View File

@ -1,7 +1,7 @@
const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context');
describe('sale refund()', () => {
describe('Sale refund()', () => {
const userId = 5;
const activeCtx = {
accessToken: {userId: userId},
@ -22,7 +22,7 @@ describe('sale refund()', () => {
try {
const options = {transaction: tx};
const response = await models.Sale.refund(salesIds, servicesIds, options);
const response = await models.Sale.refund(salesIds, servicesIds, false, options);
expect(response.length).toBeGreaterThanOrEqual(1);
@ -40,7 +40,8 @@ describe('sale refund()', () => {
try {
const options = {transaction: tx};
const tickets = await models.Sale.refund(salesIds, servicesIds, options);
const createSingleTicket = false;
const tickets = await models.Sale.refund(salesIds, servicesIds, createSingleTicket, options);
const ticketsIds = tickets.map(ticket => ticket.id);