29 lines
855 B
JavaScript
29 lines
855 B
JavaScript
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;
|
|
}
|
|
});
|
|
});
|
|
|