salix/modules/worker/back/methods/worker-dms/specs/downloadFile.spec.js

28 lines
800 B
JavaScript
Raw Normal View History

2020-04-03 15:52:47 +00:00
const app = require('vn-loopback/server/server');
describe('worker-dms downloadFile()', () => {
let dmsId = 4;
it('should return a response for an employee with text content-type', async() => {
let workerId = 106;
let ctx = {req: {accessToken: {userId: workerId}}};
const result = await app.models.WorkerDms.downloadFile(ctx, dmsId);
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 {
await app.models.WorkerDms.downloadFile(ctx, dmsId);
} catch (e) {
error = e;
}
expect(error).toBeDefined();
});
});