2021-10-07 07:57:07 +00:00
|
|
|
const models = require('vn-loopback/server/server').models;
|
2023-04-12 10:33:14 +00:00
|
|
|
const LoopBackContext = require('loopback-context');
|
2019-07-25 07:55:09 +00:00
|
|
|
|
|
|
|
describe('ticket-request deny()', () => {
|
2023-04-12 10:33:14 +00:00
|
|
|
beforeAll(async() => {
|
|
|
|
const activeCtx = {
|
|
|
|
accessToken: {userId: 9},
|
|
|
|
http: {
|
|
|
|
req: {
|
|
|
|
headers: {origin: 'http://localhost'}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
|
|
active: activeCtx
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-11-10 10:44:29 +00:00
|
|
|
it('should return the denied ticket request', async() => {
|
2021-10-07 07:57:07 +00:00
|
|
|
const tx = await models.TicketRequest.beginTransaction({});
|
2019-07-25 07:55:09 +00:00
|
|
|
|
2021-10-07 07:57:07 +00:00
|
|
|
try {
|
|
|
|
const options = {transaction: tx};
|
2019-07-25 07:55:09 +00:00
|
|
|
|
2021-11-10 10:44:29 +00:00
|
|
|
const ctx = {
|
|
|
|
req: {
|
|
|
|
accessToken: {userId: 9},
|
|
|
|
headers: {origin: 'http://localhost'}
|
|
|
|
},
|
|
|
|
args: {id: 4, observation: 'my observation'},
|
|
|
|
};
|
|
|
|
|
|
|
|
ctx.req.__ = value => {
|
|
|
|
return value;
|
|
|
|
};
|
2019-07-25 07:55:09 +00:00
|
|
|
|
2021-10-07 07:57:07 +00:00
|
|
|
const result = await models.TicketRequest.deny(ctx, options);
|
2019-07-25 07:55:09 +00:00
|
|
|
|
2021-10-07 07:57:07 +00:00
|
|
|
expect(result.id).toEqual(4);
|
2019-07-25 07:55:09 +00:00
|
|
|
|
2021-10-07 07:57:07 +00:00
|
|
|
await tx.rollback();
|
|
|
|
} catch (e) {
|
|
|
|
await tx.rollback();
|
|
|
|
throw e;
|
|
|
|
}
|
2019-07-25 07:55:09 +00:00
|
|
|
});
|
|
|
|
});
|