test: refs #7615 add test to setDeleted
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Alex Moreno 2024-07-23 12:23:31 +02:00
parent 4259339afb
commit 8845f78383
1 changed files with 34 additions and 13 deletions

View File

@ -76,21 +76,42 @@ describe('ticket setDeleted()', () => {
}
});
it('should show error trying to delete a ticket with a refund', async() => {
const tx = await models.Ticket.beginTransaction({});
let error;
try {
const options = {transaction: tx};
describe('ticket with refund setDeleted()', () => {
it('should show error trying to delete a ticket with a refund', async() => {
const tx = await models.Ticket.beginTransaction({});
let error;
try {
const options = {transaction: tx};
const ticketId = 8;
await models.Ticket.setDeleted(ctx, ticketId, options);
const ticketId = 8;
await models.Ticket.setDeleted(ctx, ticketId, options);
await tx.rollback();
} catch (e) {
await tx.rollback();
error = e;
}
await tx.rollback();
} catch (e) {
await tx.rollback();
error = e;
}
expect(error.message).toContain('Tickets with associated refunds');
expect(error.message).toContain('Tickets with associated refunds');
});
it('should delete a ticket with a refund if ticket refund is deleted', async() => {
const tx = await models.Ticket.beginTransaction({});
try {
const options = {transaction: tx};
const ticketId = 8;
const ticketRefundId = 24;
await models.Ticket.updateAll({id: ticketRefundId}, {isDeleted: true}, options);
await models.Ticket.setDeleted(ctx, ticketId, options);
await tx.rollback();
} catch (e) {
await tx.rollback();
error = e;
}
expect(error.message).not.toContain('Tickets with associated refunds');
});
});
});