31 lines
1002 B
JavaScript
31 lines
1002 B
JavaScript
const app = require('vn-loopback/server/server');
|
|
|
|
describe('Worker absences()', () => {
|
|
it('should import sales to a claim actions from an specific ticket', 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);
|
|
// Last day of previous month (January)
|
|
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(15);
|
|
expect(calendar.holidaysEnjoyed).toEqual(5);
|
|
|
|
expect(absences[0].absenceType().id).toEqual(2);
|
|
expect(absences[5].absenceType().id).toEqual(1);
|
|
});
|
|
});
|