2023-04-19 11:59:26 +00:00
|
|
|
const models = require('vn-loopback/server/server').models;
|
2020-04-03 15:52:47 +00:00
|
|
|
|
|
|
|
describe('worker-dms downloadFile()', () => {
|
|
|
|
let dmsId = 4;
|
|
|
|
|
|
|
|
it('should return a response for an employee with text content-type', async() => {
|
2021-06-23 11:24:23 +00:00
|
|
|
let workerId = 1106;
|
2020-04-03 15:52:47 +00:00
|
|
|
let ctx = {req: {accessToken: {userId: workerId}}};
|
2023-04-19 11:59:26 +00:00
|
|
|
const result = await models.WorkerDms.downloadFile(ctx, dmsId);
|
2020-04-03 15:52:47 +00:00
|
|
|
|
|
|
|
expect(result[1]).toEqual('text/plain');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return an error for a user without enough privileges', async() => {
|
|
|
|
let clientId = 1;
|
|
|
|
let ctx = {req: {accessToken: {userId: clientId}}};
|
|
|
|
|
|
|
|
let error;
|
|
|
|
try {
|
2023-04-19 11:59:26 +00:00
|
|
|
await models.WorkerDms.downloadFile(ctx, dmsId);
|
2020-04-03 15:52:47 +00:00
|
|
|
} catch (e) {
|
|
|
|
error = e;
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(error).toBeDefined();
|
|
|
|
});
|
|
|
|
});
|