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

38 lines
996 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
}
};
});
2024-07-31 04:43:19 +00:00
it('should insert in workerActivity', async() => {
2024-07-30 10:36:02 +00:00
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);
});
});