File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 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+ } ) ;
You can’t perform that action at this time.
0 commit comments