get worked hours unit test

This commit is contained in:
Carlos Jimenez Ruiz 2020-03-03 15:14:28 +01:00
parent 41d0c1e9bf
commit 0f7ed5bbfa
3 changed files with 17 additions and 2 deletions

View File

@ -35,7 +35,6 @@ module.exports = Self => {
let sql = ParameterizedSQL.join(stmts, ';');
let result = await conn.executeStmt(sql);
return result[1];
};
};

View File

@ -0,0 +1,17 @@
const app = require('vn-loopback/server/server');
describe('Worker getWorkedHours()', () => {
it(`should return the expected hours and the worked hours of a given date`, async() => {
const workerID = 106;
let started = new Date();
started.setHours(0, 0, 0, 0);
let ended = new Date();
ended.setHours(0, 0, 0, 0);
const [result] = await app.models.Worker.getWorkedHours(workerID, started, ended);
expect(result.expectedHours).toEqual(28800); // 8:00 hours seconds
expect(result.workedHours).toEqual(29400); // 8:10 hours in seconds
});
});

View File

@ -44,7 +44,6 @@ module.exports = Self => {
let sql = ParameterizedSQL.join(stmts, ';');
let result = await conn.executeStmt(sql);
return result[0];
};
};