Skip to content

Commit

Permalink
Fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
pronein committed Apr 30, 2017
1 parent 85cfd3d commit bace2a1
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 31 deletions.
2 changes: 1 addition & 1 deletion test/multipartUploads.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,4 @@ describe('Test Upload With Fields', function() {
});
});
}
});
});
48 changes: 25 additions & 23 deletions test/options.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,31 @@ describe('File Upload Options Tests', function() {
done();
});

/**
* Upload the file for testing and verify the expected filename.
* @param {object} options The expressFileUpload options.
* @param {string} actualFileNameToUpload The name of the file to upload.
* @param {string} expectedFileNameOnFileSystem The name of the file after upload.
* @param {function} done The mocha continuation function.
*/
function executeFileUploadTestWalk(options,
actualFileNameToUpload,
expectedFileNameOnFileSystem,
done) {
request(server.setup(options))
.post('/upload/single')
.attach('testFile', path.join(fileDir, actualFileNameToUpload))
.expect(200)
.end(function(err) {
if (err)
return done(err);

const uploadedFilePath = path.join(uploadDir, expectedFileNameOnFileSystem);

fs.stat(uploadedFilePath, done);
});
}

describe('Testing [safeFileNames] option to ensure:', function() {
it('Does nothing to your filename when disabled.',
function(done) {
Expand Down Expand Up @@ -159,27 +184,4 @@ describe('File Upload Options Tests', function() {
executeFileUploadTestWalk(fileUploadOptions, actualFileName, expectedFileName, done);
});
});

function executeFileUploadTestWalk(options,
actualFileNameToUpload,
expectedFilNameOnFileSystem,
done) {
const argsUnderTest = options;
const app = server.setup(argsUnderTest);
const actualFileName = actualFileNameToUpload;
const expectedFileName = expectedFilNameOnFileSystem;

request(app)
.post('/upload/single')
.attach('testFile', path.join(fileDir, actualFileName))
.expect(200)
.end(function(err) {
if (err)
return done(err);

const uploadedFilePath = path.join(uploadDir, expectedFileName);

fs.stat(uploadedFilePath, done);
});
}
});
14 changes: 7 additions & 7 deletions test/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const clearUploadsDir = function() {
}
};

var setup = function(fileUploadOptions) {
const setup = function(fileUploadOptions) {
const express = require('express');
const expressFileupload = require('../lib/index');

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

testFile.mv(uploadPath, function (err) {
testFile.mv(uploadPath, function(err) {
if (err)
return res.status(500).send(err);

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

testFile.mv(uploadPath, function (err) {
testFile.mv(uploadPath, function(err) {
if (err)
return res.status(500).send(err);

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

testFile1.mv(uploadPath1, function (err) {
testFile1.mv(uploadPath1, function(err) {
if (err)
return res.status(500).send(err);

testFile2.mv(uploadPath2, function (err) {
testFile2.mv(uploadPath2, function(err) {
if (err)
return res.status(500).send(err);

testFile3.mv(uploadPath3, function (err) {
testFile3.mv(uploadPath3, function(err) {
if (err)
return res.status(500).send(err);

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

testFiles[i].mv(uploadPath, function (err) {
testFiles[i].mv(uploadPath, function(err) {
if (err)
return res.status(500).send(err);

Expand Down

0 comments on commit bace2a1

Please sign in to comment.