salix/back/methods/dms/specs/downloadFile.spec.js

27 lines
862 B
JavaScript
Raw Normal View History

2019-05-01 16:49:39 +00:00
const app = require('vn-loopback/server/server');
describe('dms downloadFile()', () => {
2019-05-01 16:49:39 +00:00
let dmsId = 1;
it('should return a response for an employee with text content-type', async() => {
let workerId = 107;
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');
});
it(`should return an error for a user without enough privileges`, async() => {
let clientId = 101;
let ctx = {req: {accessToken: {userId: clientId}}};
let error;
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();
});
});