mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	pass along hooks, add test to server impl
This commit is contained in:
		
							parent
							
								
									a07d04c748
								
							
						
					
					
						commit
						efe66c3ff9
					
				| @ -3,6 +3,9 @@ | |||||||
|         "finn", |         "finn", | ||||||
|         "finn/node" |         "finn/node" | ||||||
|     ], |     ], | ||||||
|  |     "parserOptions": { | ||||||
|  |         "ecmaVersion": "2017" | ||||||
|  |     }, | ||||||
|     "rules": { |     "rules": { | ||||||
|         "max-nested-callbacks": "off" |         "max-nested-callbacks": "off" | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -21,6 +21,8 @@ function createApp (options) { | |||||||
|         enableRequestLogger: options.enableRequestLogger, |         enableRequestLogger: options.enableRequestLogger, | ||||||
|         port: options.port, |         port: options.port, | ||||||
|         publicFolder: options.publicFolder, |         publicFolder: options.publicFolder, | ||||||
|  |         preRouterHook: options.preRouterHook, | ||||||
|  |         preHook: options.preHook, | ||||||
|         stores, |         stores, | ||||||
|         eventBus, |         eventBus, | ||||||
|     }; |     }; | ||||||
|  | |||||||
							
								
								
									
										51
									
								
								lib/server-impl.test.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								lib/server-impl.test.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,51 @@ | |||||||
|  | 'use strict'; | ||||||
|  | 
 | ||||||
|  | const test = require('ava'); | ||||||
|  | const proxyquire = require('proxyquire'); | ||||||
|  | 
 | ||||||
|  | const getApp = proxyquire('./app', { | ||||||
|  |     './routes': { | ||||||
|  |         createAPI: () => {}, | ||||||
|  |         createLegacy: () => {}, | ||||||
|  |     }, | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | const serverImpl = proxyquire('./server-impl', { | ||||||
|  |     './app': getApp, | ||||||
|  |     './metrics': { | ||||||
|  |         startMonitoring (o) { | ||||||
|  |             return o; | ||||||
|  |         }, | ||||||
|  |     }, | ||||||
|  |     './db': { | ||||||
|  |         createStores (o) { | ||||||
|  |             return o; | ||||||
|  |         }, | ||||||
|  |     }, | ||||||
|  |     './options': { | ||||||
|  |         createOptions (o) { | ||||||
|  |             return o; | ||||||
|  |         }, | ||||||
|  |     }, | ||||||
|  |     '../migrator' () { | ||||||
|  |         return Promise.resolve(); | ||||||
|  |     }, | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | test('should call preHook', async t => { | ||||||
|  |     let called = 0; | ||||||
|  |     await serverImpl.start({ | ||||||
|  |         preHook: () => { | ||||||
|  |             called++; | ||||||
|  |         }, | ||||||
|  |     }); | ||||||
|  |     t.true(called === 1); | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | test('should call preRouterHook', async t => { | ||||||
|  |     let called = 0; | ||||||
|  |     await serverImpl.start({ preRouterHook: () => { | ||||||
|  |         called++; | ||||||
|  |     } }); | ||||||
|  |     t.true(called === 1); | ||||||
|  | }); | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user