Skip to content

Commit

Permalink
Add file limit upload test
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Mrowiec committed Dec 6, 2017
1 parent 10263ab commit 91d944f
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/fileLimitUploads.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'use strict';

const path = require('path');
const request = require('supertest');
const server = require('./server');
const app = server.setup({
limits: {fileSize: 200 * 1024} // set 200kb upload limit
});
const fileDir = server.fileDir;

describe('Test Single File Upload With File Size Limit', function() {
it(`upload 'basketball.png' (~154kb) with 200kb size limit`, function(done) {
let filePath = path.join(fileDir, 'basketball.png');

request(app)
.post('/upload/single')
.attach('testFile', filePath)
.expect(200)
.end(done);
});

it(`fail when uploading 'car.png' (~269kb) with 200kb size limit`, function(done) {
let filePath = path.join(fileDir, 'car.png');

request(app)
.post('/upload/single')
.attach('testFile', filePath)
.expect(413)
.end(done);
});
});

0 comments on commit 91d944f

Please sign in to comment.