refactor: replace let for const
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Vicent Llopis 2022-04-11 10:09:54 +02:00
parent ddd6d61d9e
commit 6e999302bf
4 changed files with 11 additions and 14 deletions

View File

@ -16,16 +16,14 @@ module.exports = Self => {
});
Self.deleteOldFiles = async options => {
let tx;
const tx = await Self.beginTransaction({});
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
if (!myOptions.transaction)
myOptions.transaction = tx;
}
try {
const claimContainer = './storage/claim';

View File

@ -1,11 +1,11 @@
const app = require('vn-loopback/server/server');
describe('claim downloadFile()', () => {
let dmsId = 7;
const dmsId = 7;
it('should return a response for an employee with image content-type', async() => {
let workerId = 1107;
let ctx = {req: {accessToken: {userId: workerId}}};
const workerId = 1107;
const ctx = {req: {accessToken: {userId: workerId}}};
const result = await app.models.Claim.downloadFile(ctx, dmsId);
expect(result[1]).toEqual('image/jpeg');

View File

@ -2,9 +2,9 @@ const app = require('vn-loopback/server/server');
describe('claim uploadFile()', () => {
it(`should return an error for a user without enough privileges`, async() => {
let clientId = 1101;
let ticketDmsTypeId = 14;
let ctx = {req: {accessToken: {userId: clientId}}, args: {dmsTypeId: ticketDmsTypeId}};
const clientId = 1101;
const ticketDmsTypeId = 14;
const ctx = {req: {accessToken: {userId: clientId}}, args: {dmsTypeId: ticketDmsTypeId}};
let error;
await app.models.Claim.uploadFile(ctx).catch(e => {

View File

@ -57,16 +57,15 @@ module.exports = Self => {
});
Self.uploadFile = async(ctx, id, options) => {
let tx;
const tx = await Self.beginTransaction({});
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
if (!myOptions.transaction)
myOptions.transaction = tx;
}
const models = Self.app.models;
const promises = [];
const TempContainer = models.TempContainer;