39 lines
1015 B
JavaScript
39 lines
1015 B
JavaScript
|
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();
|
||
|
});
|
||
|
|
||
|
it('should throw an error when there is not picking tickets', async() => {
|
||
|
try {
|
||
|
await models.Collection.assign(ctx, options);
|
||
|
} catch (e) {
|
||
|
expect(e.message).toEqual('There are not picking tickets');
|
||
|
}
|
||
|
});
|
||
|
});
|