41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
const app = require('vn-loopback/server/server');
|
|
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
|
|
|
describe('timeBusiness_calculateByUser()', () => {
|
|
it('should return the expected hours for today', async() => {
|
|
let start = new Date();
|
|
start.setHours(0, 0, 0, 0);
|
|
let end = new Date();
|
|
end.setHours(0, 0, 0, 0);
|
|
|
|
let stmts = [];
|
|
let stmt;
|
|
|
|
stmts.push('START TRANSACTION');
|
|
|
|
let params = {
|
|
workerID: 1106,
|
|
start: start,
|
|
end: end
|
|
};
|
|
|
|
stmt = new ParameterizedSQL('CALL vn.timeBusiness_calculateByUser(?, ?, ?)', [
|
|
params.workerID,
|
|
params.start,
|
|
params.end
|
|
]);
|
|
stmts.push(stmt);
|
|
|
|
let tableIndex = stmts.push('SELECT * FROM tmp.timeBusinessCalculate') - 1;
|
|
|
|
stmts.push('ROLLBACK');
|
|
|
|
let sql = ParameterizedSQL.join(stmts, ';');
|
|
let result = await app.models.Ticket.rawStmt(sql);
|
|
|
|
let [timeBusinessCalculateTable] = result[tableIndex];
|
|
|
|
expect(timeBusinessCalculateTable.timeBusinessSeconds).toEqual(28800);
|
|
});
|
|
});
|