2024-02-06 15:17:53 +00:00
|
|
|
const models = require('vn-loopback/server/server').models;
|
|
|
|
const LoopBackContext = require('loopback-context');
|
|
|
|
|
2024-05-27 06:15:57 +00:00
|
|
|
describe('ticket assignCollection()', () => {
|
2024-02-06 15:17:53 +00:00
|
|
|
let ctx;
|
|
|
|
let options;
|
|
|
|
let tx;
|
|
|
|
beforeEach(async() => {
|
|
|
|
ctx = {
|
|
|
|
req: {
|
|
|
|
accessToken: {userId: 1106},
|
|
|
|
headers: {origin: 'http://localhost'},
|
|
|
|
__: value => value
|
|
|
|
},
|
|
|
|
args: {}
|
|
|
|
};
|
|
|
|
|
2024-08-30 15:04:45 +00:00
|
|
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({active: ctx.req});
|
2024-02-06 15:17:53 +00:00
|
|
|
|
|
|
|
options = {transaction: tx};
|
|
|
|
tx = await models.Sale.beginTransaction({});
|
|
|
|
options.transaction = tx;
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(async() => {
|
2024-08-30 15:04:45 +00:00
|
|
|
if (tx) await tx.rollback();
|
2024-02-06 15:17:53 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should throw an error when there is not picking tickets', async() => {
|
|
|
|
try {
|
|
|
|
await models.Collection.assignCollection(ctx, options);
|
|
|
|
} catch (e) {
|
|
|
|
expect(e.message).toEqual('There are not picking tickets');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|