You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							47 lines
						
					
					
						
							929 B
						
					
					
				
			
		
		
	
	
							47 lines
						
					
					
						
							929 B
						
					
					
				| 'use strict'
 | |
| 
 | |
| const Fastify = require('..')
 | |
| const sget = require('simple-get').concat
 | |
| const t = require('tap')
 | |
| const test = t.test
 | |
| 
 | |
| test('bodyLimit', t => {
 | |
|   t.plan(5)
 | |
| 
 | |
|   try {
 | |
|     Fastify({ bodyLimit: 1.3 })
 | |
|     t.fail('option must be an integer')
 | |
|   } catch (err) {
 | |
|     t.ok(err)
 | |
|   }
 | |
| 
 | |
|   try {
 | |
|     Fastify({ bodyLimit: [] })
 | |
|     t.fail('option must be an integer')
 | |
|   } catch (err) {
 | |
|     t.ok(err)
 | |
|   }
 | |
| 
 | |
|   const fastify = Fastify({ bodyLimit: 1 })
 | |
| 
 | |
|   fastify.post('/', (request, reply) => {
 | |
|     reply.send({ error: 'handler should not be called' })
 | |
|   })
 | |
| 
 | |
|   fastify.listen(0, function (err) {
 | |
|     t.error(err)
 | |
|     fastify.server.unref()
 | |
| 
 | |
|     sget({
 | |
|       method: 'POST',
 | |
|       url: 'http://localhost:' + fastify.server.address().port,
 | |
|       headers: { 'Content-Type': 'application/json' },
 | |
|       body: [],
 | |
|       json: true
 | |
|     }, (err, response, body) => {
 | |
|       t.error(err)
 | |
|       t.equal(response.statusCode, 413)
 | |
|     })
 | |
|   })
 | |
| })
 |