feat: add backTest
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
11459bbd56
commit
8d7296cc8f
|
@ -1,6 +1,6 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('workerTimeControl sendMail()', () => {
|
||||
fdescribe('workerTimeControl sendMail()', () => {
|
||||
const workerId = 18;
|
||||
const ctx = {
|
||||
req: {
|
||||
|
@ -17,7 +17,7 @@ describe('workerTimeControl sendMail()', () => {
|
|||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
|
||||
});
|
||||
|
||||
it('should fill time control of a worker without records in Journey and and with rest', async() => {
|
||||
it('should fill time control of a worker without records in Journey and with rest', async() => {
|
||||
const tx = await models.WorkerTimeControl.beginTransaction({});
|
||||
|
||||
try {
|
||||
|
@ -41,7 +41,7 @@ describe('workerTimeControl sendMail()', () => {
|
|||
}
|
||||
});
|
||||
|
||||
it('should fill time control of a worker without records in Journey and and without rest', async() => {
|
||||
it('should fill time control of a worker without records in Journey and without rest', async() => {
|
||||
const workdayOf20Hours = 3;
|
||||
const tx = await models.WorkerTimeControl.beginTransaction({});
|
||||
|
||||
|
@ -68,7 +68,7 @@ describe('workerTimeControl sendMail()', () => {
|
|||
}
|
||||
});
|
||||
|
||||
it('should fill time control of a worker with records in Journey', async() => {
|
||||
it('should fill time control of a worker with records in Journey and with rest', async() => {
|
||||
const tx = await models.WorkerTimeControl.beginTransaction({});
|
||||
|
||||
try {
|
||||
|
@ -76,8 +76,7 @@ describe('workerTimeControl sendMail()', () => {
|
|||
query = `INSERT INTO postgresql.journey(journey_id, day_id, start, end, business_id)
|
||||
VALUES
|
||||
(1, 1, '09:00:00', '13:00:00', ?),
|
||||
(2, 1, '14:00:00', '19:00:00', ?),
|
||||
(3, 2, '12:30:00', '19:00:00', ?);`;
|
||||
(2, 1, '14:00:00', '19:00:00', ?);`;
|
||||
await models.WorkerTimeControl.rawSql(query, [workerId, workerId, workerId], options);
|
||||
|
||||
await models.WorkerTimeControl.sendMail(ctx, options);
|
||||
|
@ -100,6 +99,32 @@ describe('workerTimeControl sendMail()', () => {
|
|||
}
|
||||
});
|
||||
|
||||
it('should fill time control of a worker with records in Journey and without rest', async() => {
|
||||
const tx = await models.WorkerTimeControl.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
query = `INSERT INTO postgresql.journey(journey_id, day_id, start, end, business_id)
|
||||
VALUES
|
||||
(1, 1, '12:30:00', '14:00:00', ?);`;
|
||||
await models.WorkerTimeControl.rawSql(query, [workerId, workerId, workerId], options);
|
||||
|
||||
await models.WorkerTimeControl.sendMail(ctx, options);
|
||||
|
||||
const workerTimeControl = await models.WorkerTimeControl.find({
|
||||
where: {userFk: workerId}
|
||||
}, options);
|
||||
|
||||
expect(`${workerTimeControl[0].timed.getHours()}:${workerTimeControl[0].timed.getMinutes()}`).toEqual('12:30');
|
||||
expect(workerTimeControl[1].timed.getHours()).toEqual(14);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
afterAll(function() {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue