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.
		
		
		
		
		
			
		
			
				
					29 lines
				
				1.3 KiB
			
		
		
			
		
	
	
					29 lines
				
				1.3 KiB
			| 
								 
											3 years ago
										 
									 | 
							
								'use strict'
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								const t = require('tap')
							 | 
						||
| 
								 | 
							
								const FindMyWay = require('../')
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								const findMyWay = FindMyWay({
							 | 
						||
| 
								 | 
							
								  defaultRoute: (req, res) => {
							 | 
						||
| 
								 | 
							
								    t.fail('Should not be defaultRoute')
							 | 
						||
| 
								 | 
							
								  }
							 | 
						||
| 
								 | 
							
								})
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								findMyWay.on('GET', '/a', (req, res) => {
							 | 
						||
| 
								 | 
							
								  res.end('{"message":"hello world"}')
							 | 
						||
| 
								 | 
							
								})
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								findMyWay.on('GET', '/a/:id', (req, res) => {
							 | 
						||
| 
								 | 
							
								  res.end('{"message":"hello world"}')
							 | 
						||
| 
								 | 
							
								})
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								t.same(findMyWay.find('GET', 'http://localhost/a', { host: 'localhost' }), findMyWay.find('GET', '/a', { host: 'localhost' }))
							 | 
						||
| 
								 | 
							
								t.same(findMyWay.find('GET', 'http://localhost:8080/a', { host: 'localhost' }), findMyWay.find('GET', '/a', { host: 'localhost' }))
							 | 
						||
| 
								 | 
							
								t.same(findMyWay.find('GET', 'http://123.123.123.123/a', {}), findMyWay.find('GET', '/a', {}))
							 | 
						||
| 
								 | 
							
								t.same(findMyWay.find('GET', 'https://localhost/a', { host: 'localhost' }), findMyWay.find('GET', '/a', { host: 'localhost' }))
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								t.same(findMyWay.find('GET', 'http://localhost/a/100', { host: 'localhost' }), findMyWay.find('GET', '/a/100', { host: 'localhost' }))
							 | 
						||
| 
								 | 
							
								t.same(findMyWay.find('GET', 'http://localhost:8080/a/100', { host: 'localhost' }), findMyWay.find('GET', '/a/100', { host: 'localhost' }))
							 | 
						||
| 
								 | 
							
								t.same(findMyWay.find('GET', 'http://123.123.123.123/a/100', {}), findMyWay.find('GET', '/a/100', {}))
							 | 
						||
| 
								 | 
							
								t.same(findMyWay.find('GET', 'https://localhost/a/100', { host: 'localhost' }), findMyWay.find('GET', '/a/100', { host: 'localhost' }))
							 |