Skip to content

Commit bace2a1

Browse files
committed
Fix linting issues
1 parent 85cfd3d commit bace2a1

File tree

3 files changed

+33
-31
lines changed

3 files changed

+33
-31
lines changed

test/multipartUploads.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -212,4 +212,4 @@ describe('Test Upload With Fields', function() {
212212
});
213213
});
214214
}
215-
});
215+
});

test/options.spec.js

+25-23
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,31 @@ describe('File Upload Options Tests', function() {
1212
done();
1313
});
1414

15+
/**
16+
* Upload the file for testing and verify the expected filename.
17+
* @param {object} options The expressFileUpload options.
18+
* @param {string} actualFileNameToUpload The name of the file to upload.
19+
* @param {string} expectedFileNameOnFileSystem The name of the file after upload.
20+
* @param {function} done The mocha continuation function.
21+
*/
22+
function executeFileUploadTestWalk(options,
23+
actualFileNameToUpload,
24+
expectedFileNameOnFileSystem,
25+
done) {
26+
request(server.setup(options))
27+
.post('/upload/single')
28+
.attach('testFile', path.join(fileDir, actualFileNameToUpload))
29+
.expect(200)
30+
.end(function(err) {
31+
if (err)
32+
return done(err);
33+
34+
const uploadedFilePath = path.join(uploadDir, expectedFileNameOnFileSystem);
35+
36+
fs.stat(uploadedFilePath, done);
37+
});
38+
}
39+
1540
describe('Testing [safeFileNames] option to ensure:', function() {
1641
it('Does nothing to your filename when disabled.',
1742
function(done) {
@@ -159,27 +184,4 @@ describe('File Upload Options Tests', function() {
159184
executeFileUploadTestWalk(fileUploadOptions, actualFileName, expectedFileName, done);
160185
});
161186
});
162-
163-
function executeFileUploadTestWalk(options,
164-
actualFileNameToUpload,
165-
expectedFilNameOnFileSystem,
166-
done) {
167-
const argsUnderTest = options;
168-
const app = server.setup(argsUnderTest);
169-
const actualFileName = actualFileNameToUpload;
170-
const expectedFileName = expectedFilNameOnFileSystem;
171-
172-
request(app)
173-
.post('/upload/single')
174-
.attach('testFile', path.join(fileDir, actualFileName))
175-
.expect(200)
176-
.end(function(err) {
177-
if (err)
178-
return done(err);
179-
180-
const uploadedFilePath = path.join(uploadDir, expectedFileName);
181-
182-
fs.stat(uploadedFilePath, done);
183-
});
184-
}
185187
});

test/server.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const clearUploadsDir = function() {
1212
}
1313
};
1414

15-
var setup = function(fileUploadOptions) {
15+
const setup = function(fileUploadOptions) {
1616
const express = require('express');
1717
const expressFileupload = require('../lib/index');
1818

@@ -28,7 +28,7 @@ var setup = function(fileUploadOptions) {
2828
let testFile = req.files.testFile;
2929
let uploadPath = path.join(uploadDir, testFile.name);
3030

31-
testFile.mv(uploadPath, function (err) {
31+
testFile.mv(uploadPath, function(err) {
3232
if (err)
3333
return res.status(500).send(err);
3434

@@ -55,7 +55,7 @@ var setup = function(fileUploadOptions) {
5555
let testFile = req.files.testFile;
5656
let uploadPath = path.join(uploadDir, testFile.name);
5757

58-
testFile.mv(uploadPath, function (err) {
58+
testFile.mv(uploadPath, function(err) {
5959
if (err)
6060
return res.status(500).send(err);
6161

@@ -87,15 +87,15 @@ var setup = function(fileUploadOptions) {
8787
if (!testFile3)
8888
return res.status(400).send('testFile3 was not uploaded');
8989

90-
testFile1.mv(uploadPath1, function (err) {
90+
testFile1.mv(uploadPath1, function(err) {
9191
if (err)
9292
return res.status(500).send(err);
9393

94-
testFile2.mv(uploadPath2, function (err) {
94+
testFile2.mv(uploadPath2, function(err) {
9595
if (err)
9696
return res.status(500).send(err);
9797

98-
testFile3.mv(uploadPath3, function (err) {
98+
testFile3.mv(uploadPath3, function(err) {
9999
if (err)
100100
return res.status(500).send(err);
101101

@@ -124,7 +124,7 @@ var setup = function(fileUploadOptions) {
124124
for (let i = 0; i < testFiles.length; i++) {
125125
let uploadPath = path.join(uploadDir, testFiles[i].name);
126126

127-
testFiles[i].mv(uploadPath, function (err) {
127+
testFiles[i].mv(uploadPath, function(err) {
128128
if (err)
129129
return res.status(500).send(err);
130130

0 commit comments

Comments
 (0)