From 91d944f50429d451842c1c8deb1c92d1ab9d7d5b Mon Sep 17 00:00:00 2001 From: Mateusz Mrowiec Date: Wed, 6 Dec 2017 07:15:56 +0100 Subject: [PATCH] Add file limit upload test --- test/fileLimitUploads.spec.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 test/fileLimitUploads.spec.js diff --git a/test/fileLimitUploads.spec.js b/test/fileLimitUploads.spec.js new file mode 100644 index 0000000..852319f --- /dev/null +++ b/test/fileLimitUploads.spec.js @@ -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); + }); +});