feat: add backTest
gitea/salix/pipeline/head This commit is unstable Details

This commit is contained in:
Vicent Llopis 2022-07-05 10:19:22 +02:00
parent 51bd18ac37
commit 979ee1d956
1 changed files with 51 additions and 0 deletions

View File

@ -0,0 +1,51 @@
const models = require('vn-loopback/server/server').models;
describe('route updateWorkCenter()', () => {
const routeId = 1;
it('should update the commissionWorkCenterFk from workerLabour.workCenterFK', async() => {
const tx = await models.Defaulter.beginTransaction({});
try {
const developerId = 9;
const ctx = {
req: {
accessToken: {userId: developerId}
}
};
const options = {transaction: tx};
const expectedResult = 1;
const updatedRoute = await models.Route.updateWorkCenter(ctx, routeId, options);
expect(updatedRoute.commissionWorkCenterFk).toEqual(expectedResult);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should update the commissionWorkCenterFk from defaultWorkCenterFk if workerLabour.workCenterFK is null', async() => {
const tx = await models.Defaulter.beginTransaction({});
try {
const noExistentId = 2;
const ctx = {
req: {
accessToken: {userId: noExistentId}
}
};
const options = {transaction: tx};
const expectedResult = 9;
const updatedRoute = await models.Route.updateWorkCenter(ctx, routeId, options);
expect(updatedRoute.commissionWorkCenterFk).toEqual(expectedResult);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});