feat(worker_createAbsense): update backTest

This commit is contained in:
Vicent Llopis 2021-11-22 13:34:42 +01:00
parent 00a33fabb3
commit cdf7c20b16
1 changed files with 6 additions and 10 deletions

View File

@ -75,7 +75,7 @@ describe('Worker createAbsence()', () => {
} }
}); });
it('should return an error trying to create a "Half holiday" absence', async() => { it(`should throw an error when adding a "Half holiday" absence if there's already one`, async() => {
const ctx = { const ctx = {
req: {accessToken: {userId: 19}}, req: {accessToken: {userId: 19}},
args: { args: {
@ -88,22 +88,18 @@ describe('Worker createAbsence()', () => {
const tx = await app.models.Calendar.beginTransaction({}); const tx = await app.models.Calendar.beginTransaction({});
let error;
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
let error; await app.models.Worker.createAbsence(ctx, workerId, options);
await app.models.Worker.createAbsence(ctx, workerId, options).catch(e => {
error = e;
}).finally(() => {
expect(error.message).toEqual(`Cannot add more than one '1/2 day vacation'`);
});
expect(error).toBeDefined();
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {
await tx.rollback(); await tx.rollback();
throw e; error = e;
} }
expect(error.message).toEqual(`Cannot add more than one '1/2 day vacation'`);
}); });
}); });