2021-10-07 07:57:07 +00:00
|
|
|
const models = require('vn-loopback/server/server').models;
|
2019-05-01 16:49:39 +00:00
|
|
|
|
2019-06-06 11:59:11 +00:00
|
|
|
describe('TicketDms removeFile()', () => {
|
|
|
|
const ticketDmsId = 1;
|
2019-05-01 16:49:39 +00:00
|
|
|
it(`should return an error for a user without enough privileges`, async() => {
|
2021-10-07 07:57:07 +00:00
|
|
|
const tx = await models.TicketDms.beginTransaction({});
|
2019-05-01 16:49:39 +00:00
|
|
|
|
|
|
|
let error;
|
2021-10-07 07:57:07 +00:00
|
|
|
try {
|
|
|
|
const options = {transaction: tx};
|
|
|
|
|
|
|
|
const clientId = 1101;
|
|
|
|
const ctx = {req: {accessToken: {userId: clientId}}};
|
|
|
|
|
|
|
|
await models.TicketDms.removeFile(ctx, ticketDmsId, options);
|
|
|
|
|
|
|
|
await tx.rollback();
|
|
|
|
} catch (e) {
|
|
|
|
await tx.rollback();
|
2019-05-01 16:49:39 +00:00
|
|
|
error = e;
|
2021-10-07 07:57:07 +00:00
|
|
|
}
|
2019-05-01 16:49:39 +00:00
|
|
|
|
2021-10-07 07:57:07 +00:00
|
|
|
expect(error.message).toEqual(`You don't have enough privileges`);
|
2019-05-01 16:49:39 +00:00
|
|
|
});
|
|
|
|
});
|