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

31 lines
821 B
JavaScript
Raw Normal View History

2024-07-30 10:36:02 +00:00
const {models} = require('vn-loopback');
describe('workerActivity insert()', () => {
2024-08-06 14:34:46 +00:00
const ctx = beforeAll.getCtx(1106);
2024-07-30 10:36:02 +00:00
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({});
2024-08-06 14:34:46 +00:00
let count = 0;
const options = {transaction: tx};
2024-07-30 10:36:02 +00:00
try {
await models.WorkerActivityType.create(
{'code': 'TEST', 'description': 'TEST'}, options
2024-07-30 10:36:02 +00:00
);
await models.WorkerActivity.add(ctx, 'TEST', 'APP', options);
2024-08-06 14:34:46 +00:00
count = await models.WorkerActivity.count(
{'workerFK': 1106}, options
);
2024-07-30 10:36:02 +00:00
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
expect(count).toEqual(1);
});
});