33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
const app = require('vn-loopback/server/server');
|
|
|
|
describe('Worker absences()', () => {
|
|
it('should get the absence calendar for the given dates then evaluate the type of absences', async() => {
|
|
let ctx = {req: {accessToken: {userId: 106}}};
|
|
let workerFk = 106;
|
|
|
|
const started = new Date();
|
|
started.setHours(0, 0, 0, 0);
|
|
started.setMonth(0);
|
|
started.setDate(1);
|
|
|
|
const monthIndex = 11;
|
|
const ended = new Date();
|
|
ended.setHours(0, 0, 0, 0);
|
|
ended.setMonth(monthIndex + 1);
|
|
ended.setDate(0);
|
|
|
|
let result = await app.models.WorkerCalendar.absences(ctx, workerFk, started, ended);
|
|
let calendar = result[0];
|
|
let absences = result[1];
|
|
|
|
expect(calendar.totalHolidays).toEqual(21);
|
|
expect(calendar.holidaysEnjoyed).toEqual(5);
|
|
|
|
let firstType = absences[0].absenceType().name;
|
|
let sixthType = absences[5].absenceType().name;
|
|
|
|
expect(firstType).toEqual('Leave of absence');
|
|
expect(sixthType).toEqual('Holidays');
|
|
});
|
|
});
|