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.
		
		
		
		
		
			
		
			
				
					
					
						
							33 lines
						
					
					
						
							632 B
						
					
					
				
			
		
		
	
	
							33 lines
						
					
					
						
							632 B
						
					
					
				| 'use strict'
 | |
| 
 | |
| const { test } = require('tap')
 | |
| const Fastify = require('..')
 | |
| 
 | |
| test('Should accept a custom genReqId function', t => {
 | |
|   t.plan(4)
 | |
| 
 | |
|   const fastify = Fastify({
 | |
|     genReqId: function (req) {
 | |
|       return 'a'
 | |
|     }
 | |
|   })
 | |
| 
 | |
|   fastify.get('/', (req, reply) => {
 | |
|     t.ok(req.id)
 | |
|     reply.send({ id: req.id })
 | |
|   })
 | |
| 
 | |
|   fastify.listen(0, err => {
 | |
|     t.error(err)
 | |
|     fastify.inject({
 | |
|       method: 'GET',
 | |
|       url: 'http://localhost:' + fastify.server.address().port
 | |
|     }, (err, res) => {
 | |
|       t.error(err)
 | |
|       const payload = JSON.parse(res.payload)
 | |
|       t.equal(payload.id, 'a')
 | |
|       fastify.close()
 | |
|     })
 | |
|   })
 | |
| })
 |