node_modules/express-fileupload/test/tempFile.spec.js
/**
   * 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.
   */
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.
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
  ) {
    let filePath = path.join(fileDir, actualFileNameToUpload);
    let fileBuffer = fs.readFileSync(filePath);
    let fileHash = md5(fileBuffer);
    let fileStat = fs.statSync(filePath);
    let uploadedFilePath = path.join(uploadDir, expectedFileNameOnFileSystem);
    request(
      server.setup(options)
    )
      .post('/upload/single')
      .attach('testFile', filePath)
      .expect((res)=>{
        res.body.uploadDir = '';
        res.body.uploadPath = '';
      })
      .expect(200, {
        name: expectedFileNameOnFileSystem,
        md5: fileHash,
        size: fileStat.size,
        uploadDir: '',
        uploadPath: ''
      })
      .end(function(err) {
        if (err) {
          return done(err);
        }
        fs.stat(uploadedFilePath, done);
      });
  }
function executeFileUploadTestWalk ( options , actualFileNameToUpload , expectedFileNameOnFileSystem , done ) { let filePath = path . join ( fileDir , actualFileNameToUpload ) ; let fileBuffer = fs . readFileSync ( filePath ) ; let fileHash = md5 ( fileBuffer ) ; let fileStat = fs . statSync ( filePath ) ; let uploadedFilePath = path . join ( uploadDir , expectedFileNameOnFileSystem ) ; request ( server . setup ( options ) ) . post ( '/upload/single' ) . attach ( 'testFile' , filePath ) . expect ( ( res ) => { res . body . uploadDir = '' ; res . body . uploadPath = '' ; } ) . expect ( 200 , { name : expectedFileNameOnFileSystem , md5 : fileHash , size : fileStat . size , uploadDir : '' , uploadPath : '' } ) . end ( function ( err ) { if ( err ) { return done ( err ) ; } fs . stat ( uploadedFilePath , done ) ; } ) ; }
Upload the file for testing and verify the expected filename.
Upload the file for testing and verify the expected filename .