29 lines
785 B
JavaScript
29 lines
785 B
JavaScript
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();
|
|
}
|
|
});
|
|
});
|