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.
		
		
		
		
		
			
		
			
				
					
					
						
							36 lines
						
					
					
						
							818 B
						
					
					
				
			
		
		
	
	
							36 lines
						
					
					
						
							818 B
						
					
					
				| 'use strict'
 | |
| 
 | |
| const t = require('tap')
 | |
| const test = t.test
 | |
| const Fastify = require('../..')
 | |
| const supportedMethods = ['DELETE', 'GET', 'HEAD', 'PATCH', 'POST', 'PUT', 'OPTIONS']
 | |
| 
 | |
| test('fastify.all should add all the methods to the same url', t => {
 | |
|   t.plan(supportedMethods.length * 2)
 | |
| 
 | |
|   const fastify = Fastify()
 | |
| 
 | |
|   fastify.all('/', (req, reply) => {
 | |
|     reply.send({ method: req.raw.method })
 | |
|   })
 | |
| 
 | |
|   supportedMethods.forEach(injectRequest)
 | |
| 
 | |
|   function injectRequest (method) {
 | |
|     const options = {
 | |
|       url: '/',
 | |
|       method
 | |
|     }
 | |
| 
 | |
|     if (method === 'POST' || method === 'PUT' || method === 'PATCH') {
 | |
|       options.payload = { hello: 'world' }
 | |
|     }
 | |
| 
 | |
|     fastify.inject(options, (err, res) => {
 | |
|       t.error(err)
 | |
|       const payload = JSON.parse(res.payload)
 | |
|       t.same(payload, { method })
 | |
|     })
 | |
|   }
 | |
| })
 |