@@ -118,13 +118,7 @@ it('deleting context.result, does not skip method call', async () => {
118118 await next ( ) ;
119119 } ;
120120
121- const fn = hooks (
122- hello ,
123- middleware ( [
124- updateResult ,
125- deleteResult ,
126- ] ) ,
127- ) ;
121+ const fn = hooks ( hello , middleware ( [ updateResult , deleteResult ] ) ) ;
128122 const res = await fn ( 'There' ) ;
129123
130124 assertStrictEquals ( res , 'There' ) ;
@@ -169,27 +163,33 @@ it('uses hooks from context object and its prototypes', async () => {
169163 const o1 = { message : 'Hi' } ;
170164 const o2 = Object . create ( o1 ) ;
171165
172- setMiddleware ( o1 , [ async ( ctx : HookContext , next : NextFunction ) => {
173- ctx . arguments [ 0 ] += ' o1' ;
166+ setMiddleware ( o1 , [
167+ async ( ctx : HookContext , next : NextFunction ) => {
168+ ctx . arguments [ 0 ] += ' o1' ;
174169
175- await next ( ) ;
176- } ] ) ;
170+ await next ( ) ;
171+ } ,
172+ ] ) ;
177173
178- setMiddleware ( o2 , [ async ( ctx , next ) => {
179- ctx . arguments [ 0 ] += ' o2' ;
174+ setMiddleware ( o2 , [
175+ async ( ctx , next ) => {
176+ ctx . arguments [ 0 ] += ' o2' ;
180177
181- await next ( ) ;
182- } ] ) ;
178+ await next ( ) ;
179+ } ,
180+ ] ) ;
183181
184182 o2 . sayHi = hooks (
185183 async function ( this : any , name : string ) {
186184 return `${ this . message } ${ name } ` ;
187185 } ,
188- middleware ( [ async ( ctx , next ) => {
189- ctx . arguments [ 0 ] += ' fn' ;
186+ middleware ( [
187+ async ( ctx , next ) => {
188+ ctx . arguments [ 0 ] += ' fn' ;
190189
191- await next ( ) ;
192- } ] ) ,
190+ await next ( ) ;
191+ } ,
192+ ] ) ,
193193 ) ;
194194
195195 const res = await o2 . sayHi ( 'Dave' ) ;
@@ -283,7 +283,9 @@ it('assigns props to context', async () => {
283283
284284 await next ( ) ;
285285 } ,
286- ] ) . params ( 'name' ) . props ( { dev : true } ) ,
286+ ] )
287+ . params ( 'name' )
288+ . props ( { dev : true } ) ,
287289 ) ;
288290
289291 assertStrictEquals ( await fn ( 'Dave' ) , 'Hello Changed' ) ;
@@ -292,19 +294,22 @@ it('assigns props to context', async () => {
292294it ( 'assigns props to context by options' , async ( ) => {
293295 const fn = hooks (
294296 hello ,
295- middleware ( [
296- async ( ctx , next ) => {
297- assertStrictEquals ( ctx . name , 'Dave' ) ;
298- assertStrictEquals ( ctx . dev , true ) ;
299-
300- ctx . name = 'Changed' ;
301-
302- await next ( ) ;
297+ middleware (
298+ [
299+ async ( ctx , next ) => {
300+ assertStrictEquals ( ctx . name , 'Dave' ) ;
301+ assertStrictEquals ( ctx . dev , true ) ;
302+
303+ ctx . name = 'Changed' ;
304+
305+ await next ( ) ;
306+ } ,
307+ ] ,
308+ {
309+ params : [ 'name' ] ,
310+ props : { dev : true } ,
303311 } ,
304- ] , {
305- params : [ 'name' ] ,
306- props : { dev : true } ,
307- } ) ,
312+ ) ,
308313 ) ;
309314
310315 assertStrictEquals ( await fn ( 'Dave' ) , 'Hello Changed' ) ;
@@ -443,7 +448,6 @@ it('context has own properties', async () => {
443448
444449 assert ( keys . includes ( 'self' ) ) ;
445450 assert ( keys . includes ( 'message' ) ) ;
446- assert ( keys . includes ( 'name' ) ) ;
447451 assert ( keys . includes ( 'arguments' ) ) ;
448452 assert ( keys . includes ( 'result' ) ) ;
449453} ) ;
@@ -468,12 +472,14 @@ it('creates context with default params', async () => {
468472
469473 await next ( ) ;
470474 } ,
471- ] ) . params ( 'name' , 'params' ) . defaults ( ( ) => {
472- return {
473- name : 'Bertho' ,
474- params : { } ,
475- } ;
476- } ) ,
475+ ] )
476+ . params ( 'name' , 'params' )
477+ . defaults ( ( ) => {
478+ return {
479+ name : 'Bertho' ,
480+ params : { } ,
481+ } ;
482+ } ) ,
477483 ) ;
478484
479485 assertStrictEquals ( await fn ( 'Dave' ) , 'Hello Dave' ) ;
0 commit comments