feat(worker_createAbsense): update backTest
This commit is contained in:
parent
00a33fabb3
commit
cdf7c20b16
|
@ -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 = {
|
||||
req: {accessToken: {userId: 19}},
|
||||
args: {
|
||||
|
@ -88,22 +88,18 @@ describe('Worker createAbsence()', () => {
|
|||
|
||||
const tx = await app.models.Calendar.beginTransaction({});
|
||||
|
||||
let error;
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
let error;
|
||||
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 app.models.Worker.createAbsence(ctx, workerId, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error.message).toEqual(`Cannot add more than one '1/2 day vacation'`);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue