4270-route.create #1023
|
@ -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({});
|
||||
vicent marked this conversation as resolved
Outdated
|
||||
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() => {
|
||||
vicent marked this conversation as resolved
Outdated
carlosjr
commented
Shoul set the default commision work center if that worker didn't have one yet Shoul set the default commision work center if that worker didn't have one yet
|
||||
const tx = await models.Defaulter.beginTransaction({});
|
||||
try {
|
||||
const noExistentId = 2;
|
||||
vicent marked this conversation as resolved
Outdated
carlosjr
commented
¿Te refieres a el user "Customer" no tiene workCenter asignado? esta variable es confusa, dale un nombre que describa realmente lo que hace. ¿Te refieres a el user "Customer" no tiene workCenter asignado? esta variable es confusa, dale un nombre que describa realmente lo que hace.
|
||||
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;
|
||||
}
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Es confuso iniciar la transacción en un modelo que no es el que vas a invocar en tu funcionalidad.
models.Defaulter vs models.Route