Skip to content

Commit 91d944f

Browse files
author
Mateusz Mrowiec
committed
Add file limit upload test
1 parent 10263ab commit 91d944f

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

test/fileLimitUploads.spec.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
'use strict';
2+
3+
const path = require('path');
4+
const request = require('supertest');
5+
const server = require('./server');
6+
const app = server.setup({
7+
limits: {fileSize: 200 * 1024} // set 200kb upload limit
8+
});
9+
const fileDir = server.fileDir;
10+
11+
describe('Test Single File Upload With File Size Limit', function() {
12+
it(`upload 'basketball.png' (~154kb) with 200kb size limit`, function(done) {
13+
let filePath = path.join(fileDir, 'basketball.png');
14+
15+
request(app)
16+
.post('/upload/single')
17+
.attach('testFile', filePath)
18+
.expect(200)
19+
.end(done);
20+
});
21+
22+
it(`fail when uploading 'car.png' (~269kb) with 200kb size limit`, function(done) {
23+
let filePath = path.join(fileDir, 'car.png');
24+
25+
request(app)
26+
.post('/upload/single')
27+
.attach('testFile', filePath)
28+
.expect(413)
29+
.end(done);
30+
});
31+
});

0 commit comments

Comments
 (0)