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.
		
		
		
		
		
			
		
			
				
					41 lines
				
				822 B
			
		
		
			
		
	
	
					41 lines
				
				822 B
			| 
											3 years ago
										 | 'use strict' | ||
|  | 
 | ||
|  | const t = require('tap') | ||
|  | const test = t.test | ||
|  | const Fastify = require('../..') | ||
|  | const h2url = require('h2url') | ||
|  | const msg = { hello: 'world' } | ||
|  | 
 | ||
|  | let fastify | ||
|  | try { | ||
|  |   fastify = Fastify({ | ||
|  |     http2: true | ||
|  |   }) | ||
|  |   t.pass('http2 successfully loaded') | ||
|  | } catch (e) { | ||
|  |   t.fail('http2 loading failed', e) | ||
|  | } | ||
|  | 
 | ||
|  | fastify.get('/', function (req, reply) { | ||
|  |   reply.code(200).send(msg) | ||
|  | }) | ||
|  | 
 | ||
|  | fastify.listen(0, err => { | ||
|  |   t.error(err) | ||
|  |   fastify.server.unref() | ||
|  | 
 | ||
|  |   test('http UNKNOWN_METHOD request', async (t) => { | ||
|  |     t.plan(2) | ||
|  | 
 | ||
|  |     const url = `http://localhost:${fastify.server.address().port}` | ||
|  |     const res = await h2url.concat({ url, method: 'UNKNOWN_METHOD' }) | ||
|  | 
 | ||
|  |     t.equal(res.headers[':status'], 404) | ||
|  |     t.same(JSON.parse(res.body), { | ||
|  |       statusCode: 404, | ||
|  |       error: 'Not Found', | ||
|  |       message: 'Not Found' | ||
|  |     }) | ||
|  |   }) | ||
|  | }) |