File tree Expand file tree Collapse file tree 5 files changed +194
-341
lines changed
Expand file tree Collapse file tree 5 files changed +194
-341
lines changed Original file line number Diff line number Diff line change 11language : node_js
22
33node_js :
4- - " 4"
5- - " 6"
64 - " 8"
75 - " node"
86
Original file line number Diff line number Diff line change 1- Copyright (c) 2012-2016 , Project contributors
1+ Copyright (c) 2012-2017 , Project contributors
22Copyright (c) 2012-2014, Walmart
33All rights reserved.
44
Original file line number Diff line number Diff line change @@ -40,19 +40,27 @@ internals.options = Joi.object().keys({
4040} ) ;
4141
4242
43- exports . inject = function ( dispatchFunc , options , callback ) {
43+ exports . inject = function ( dispatchFunc , options ) {
4444
4545 options = ( typeof options === 'string' ? { url : options } : options ) ;
4646
4747 if ( options . validate !== false ) { // Defaults to true
48- Hoek . assert ( typeof dispatchFunc === 'function' , 'Invalid dispatch function' ) ;
49- Joi . assert ( options , internals . options ) ;
48+ try {
49+ Hoek . assert ( typeof dispatchFunc === 'function' , 'Invalid dispatch function' ) ;
50+ Joi . assert ( options , internals . options ) ;
51+ }
52+ catch ( err ) {
53+ return Promise . reject ( err ) ;
54+ }
5055 }
5156
52- const req = new Request ( options ) ;
53- const res = new Response ( req , callback ) ;
57+ return new Promise ( ( resolve ) => {
5458
55- return req . prepare ( ( ) => dispatchFunc ( req , res ) ) ;
59+ const req = new Request ( options ) ;
60+ const res = new Response ( req , resolve ) ;
61+
62+ req . prepare ( ( ) => dispatchFunc ( req , res ) ) ;
63+ } ) ;
5664} ;
5765
5866
Original file line number Diff line number Diff line change 11{
22 "name" : " shot" ,
33 "description" : " Injects a fake HTTP request/response into a node HTTP server" ,
4- "version" : " 3.4.2 " ,
4+ "version" : " 4.0.0 " ,
55 "repository" : " git://github.com/hapijs/shot" ,
66 "main" : " lib/index.js" ,
77 "keywords" : [
1111 " test"
1212 ],
1313 "engines" : {
14- "node" : " >=4.5 .0"
14+ "node" : " >=8.0 .0"
1515 },
1616 "dependencies" : {
1717 "hoek" : " 4.x.x" ,
18- "joi" : " 10 .x.x"
18+ "joi" : " 11 .x.x"
1919 },
2020 "devDependencies" : {
21- "code" : " 4 .x.x" ,
22- "lab" : " 13 .x.x"
21+ "code" : " 5 .x.x" ,
22+ "lab" : " 14 .x.x"
2323 },
2424 "scripts" : {
2525 "test" : " lab -a code -t 100 -L" ,
You can’t perform that action at this time.
0 commit comments