38 lines
997 B
JavaScript
38 lines
997 B
JavaScript
|
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);
|
||
|
});
|
||
|
});
|