salix/back/methods/collection/spec/assign.spec.js

40 lines
1.1 KiB
JavaScript
Raw Normal View History

2024-03-14 07:36:19 +00:00
const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context');
describe('ticket assign()', () => {
let ctx;
let options;
let tx;
beforeEach(async() => {
ctx = {
req: {
accessToken: {userId: 1106},
headers: {origin: 'http://localhost'},
__: value => value
},
args: {}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: ctx.req
});
options = {transaction: tx};
tx = await models.Sale.beginTransaction({});
options.transaction = tx;
});
afterEach(async() => {
await tx.rollback();
});
2024-11-21 08:12:04 +00:00
it('should throw an error when there are no picking tickets', async() => {
2024-03-14 07:36:19 +00:00
try {
await models.Collection.assign(ctx, options);
2024-11-21 08:12:04 +00:00
fail('Expected an error to be thrown, but none was thrown.');
2024-03-14 07:36:19 +00:00
} catch (e) {
expect(e.message).toEqual('There are not picking tickets');
}
});
});