salix/modules/worker/back/methods/worker-time-control/specs/clockIn.spec.js

29 lines
855 B
JavaScript
Raw Normal View History

2023-12-07 13:47:22 +00:00
const models = require('vn-loopback/server/server').models;
describe('workerTimeControl clockIn()', () => {
const workerId = 9;
const inTime = '2001-01-01T00:00:00.000Z';
it('should correctly clock in', async() => {
const tx = await models.WorkerTimeControl.beginTransaction({});
try {
const options = {transaction: tx};
await models.WorkerTimeControl.clockIn(workerId, inTime, 'in', options);
const isClockIn = await models.WorkerTimeControl.findOne({
where: {
userFk: workerId
}
}, options);
expect(isClockIn).toBeDefined();
expect(isClockIn.direction).toBe('in');
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});