salix/db/tests/vn/timeBusiness_calculateByUse...

41 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2020-03-04 14:12:36 +00:00
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() => {
2023-01-16 14:18:24 +00:00
let start = Date.vnNew();
2020-03-04 14:12:36 +00:00
start.setHours(0, 0, 0, 0);
2023-01-16 14:18:24 +00:00
let end = Date.vnNew();
2020-03-04 14:12:36 +00:00
end.setHours(0, 0, 0, 0);
let stmts = [];
let stmt;
stmts.push('START TRANSACTION');
let params = {
workerID: 1106,
2020-03-04 14:12:36 +00:00
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);
});
});