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 => { Self.deleteOldFiles = async options => {
let tx; const tx = await Self.beginTransaction({});
const myOptions = {}; const myOptions = {};
if (typeof options == 'object') if (typeof options == 'object')
Object.assign(myOptions, options); Object.assign(myOptions, options);
if (!myOptions.transaction) { if (!myOptions.transaction)
tx = await Self.beginTransaction({});
myOptions.transaction = tx; myOptions.transaction = tx;
}
try { try {
const claimContainer = './storage/claim'; const claimContainer = './storage/claim';

View File

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

View File

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

View File

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