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,6 +76,7 @@ describe('ticket setDeleted()', () => {
}
});
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;
@ -93,4 +94,24 @@ describe('ticket setDeleted()', () => {
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');
});
});
});