-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9e3361a
commit 9785534
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,12 @@ const mockFiles = [ | |
'basketball.png' | ||
]; | ||
|
||
let mockUser = { | ||
firstName: 'Joe', | ||
lastName: 'Schmo', | ||
email: '[email protected]' | ||
}; | ||
|
||
describe('Test Directory Cleaning Method', function() { | ||
it('emptied "uploads" directory', function(done) { | ||
clearUploadsDir(); | ||
|
@@ -151,3 +157,34 @@ describe('Test File Array Upload', function() { | |
}); | ||
}); | ||
}); | ||
|
||
describe('Test Upload With Fields', function() { | ||
for (let i = 0; i < mockFiles.length; i++) { | ||
let fileName = mockFiles[i]; | ||
|
||
it(`upload ${fileName} and submit fields at the same time`, function(done) { | ||
let filePath = path.join(fileDir, fileName); | ||
let uploadedFilePath = path.join(uploadDir, fileName); | ||
|
||
clearUploadsDir(); | ||
|
||
request(app) | ||
.post('/upload/single/withfields') | ||
.attach('testFile', filePath) | ||
.field('firstName', mockUser.firstName) | ||
.field('lastName', mockUser.lastName) | ||
.field('email', mockUser.email) | ||
.expect(200, { | ||
firstName: mockUser.firstName, | ||
lastName: mockUser.lastName, | ||
email: mockUser.email | ||
}, | ||
function(err, res) { | ||
if (err) | ||
return done(err); | ||
|
||
fs.stat(uploadedFilePath, done); | ||
}); | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters