fix: refs #7906 remake method #3109

Merged
carlossa merged 8 commits from 7906-notDeleteZone into dev 2024-10-18 08:33:04 +00:00
1 changed files with 16 additions and 1 deletions
Showing only changes of commit 02dc952024 - Show all commits

View File

@ -9,8 +9,8 @@ describe('zone deletezone()', () => {
};
Review

Fica un test q prove el nou error "here are tickets for this area, delete them first"

Fica un test q prove el nou error "here are tickets for this area, delete them first"
const ctx = {req: activeCtx};
const zoneId = 4;
const zoneId2 = 3;
let ticketIDs;
let originalTicketStates;
beforeAll(async() => {
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
@ -44,4 +44,19 @@ describe('zone deletezone()', () => {
throw e;
}
});
it('should not delete the zone if it has tickets', async() => {
const tx = await models.Zone.beginTransaction({});
try {
const options = {transaction: tx};
await models.Zone.deleteZone(ctx, zoneId2, options);
expect(e.message).toEqual('There are tickets for this area, delete them first');
carlossa marked this conversation as resolved
Review

Fijat be

Fijat be
await tx.rollback();
} catch (e) {
await tx.rollback();
}
});
});