salix/back/methods/workerActivity/specs/add.spec.js

38 lines
997 B
JavaScript
Raw Normal View History

2024-07-30 10:36:02 +00:00
const {models} = require('vn-loopback');
describe('workerActivity insert()', () => {
beforeAll(async() => {
ctx = {
req: {
accessToken: {},
headers: {origin: 'http://localhost'},
__: value => value
}
};
});
fit('should insert in workerActivity', async() => {
const tx = await models.WorkerActivity.beginTransaction({});
try {
await models.WorkerActivityType.create(
{'code': 'STOP', 'description': 'STOP'}
);
const options = {transaction: tx};
ctx.req.accessToken.userId = 1106;
models.WorkerActivity.add(ctx, 'STOP', 'APP', options);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
const count = await models.WorkerActivity.count(
{'workerFK': 1106}
);
expect(count).toEqual(1);
});
});