salix/modules/worker/back/methods/operator/spec/add.spec.js

29 lines
785 B
JavaScript
Raw Normal View History

2024-01-19 13:35:10 +00:00
const {models} = require('vn-loopback/server/server');
describe('operator add()', () => {
beforeAll(async() => {
ctx = {
req: {
accessToken: {userId: 100000},
headers: {origin: 'http://localhost'},
__: value => value
}
};
});
it('should throw an error if the worker does not exist', async() => {
const tx = await models.Operator.beginTransaction({});
const options = {transaction: tx};
try {
await models.Operator.add(ctx, options);
await tx.rollback();
} catch (e) {
const error = e;
expect(error.message).toEqual('This worker does not exist');
await tx.rollback();
}
});
});