2019-05-01 16:49:39 +00:00
|
|
|
const app = require('vn-loopback/server/server');
|
|
|
|
|
2020-04-03 15:52:47 +00:00
|
|
|
describe('dms downloadFile()', () => {
|
2019-05-01 16:49:39 +00:00
|
|
|
let dmsId = 1;
|
2020-01-27 17:44:34 +00:00
|
|
|
|
2020-01-28 06:42:26 +00:00
|
|
|
it('should return a response for an employee with text content-type', async() => {
|
2021-06-23 11:24:23 +00:00
|
|
|
let workerId = 1107;
|
2019-06-06 11:59:11 +00:00
|
|
|
let ctx = {req: {accessToken: {userId: workerId}}};
|
|
|
|
const result = await app.models.Dms.downloadFile(ctx, dmsId);
|
2019-05-01 16:49:39 +00:00
|
|
|
|
|
|
|
expect(result[1]).toEqual('text/plain');
|
|
|
|
});
|
|
|
|
|
2020-04-03 15:52:47 +00:00
|
|
|
it('should return an error for a user without enough privileges', async() => {
|
2021-06-23 11:24:23 +00:00
|
|
|
let clientId = 1101;
|
2019-05-01 16:49:39 +00:00
|
|
|
let ctx = {req: {accessToken: {userId: clientId}}};
|
|
|
|
|
|
|
|
let error;
|
2019-06-06 11:59:11 +00:00
|
|
|
await app.models.Dms.downloadFile(ctx, dmsId).catch(e => {
|
2019-05-01 16:49:39 +00:00
|
|
|
error = e;
|
|
|
|
}).finally(() => {
|
|
|
|
expect(error.message).toEqual(`You don't have enough privileges`);
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(error).toBeDefined();
|
|
|
|
});
|
|
|
|
});
|