@@ -120,12 +120,12 @@ describe('`after` hooks', () => {
120120
121121 service . hooks ( {
122122 after : {
123- create ( hook , next ) {
123+ create ( hook ) {
124124 assert . strictEqual ( hook . type , 'after' ) ;
125125
126126 hook . result . some = 'thing' ;
127127
128- next ( null , hook ) ;
128+ return hook ;
129129 }
130130 }
131131 } ) ;
@@ -147,11 +147,11 @@ describe('`after` hooks', () => {
147147
148148 service . hooks ( {
149149 after : {
150- create ( hook , next ) {
150+ create ( hook ) {
151151 hook . result . appPresent = typeof hook . app !== 'undefined' ;
152152 assert . strictEqual ( hook . result . appPresent , true ) ;
153153
154- next ( null , hook ) ;
154+ return hook ;
155155 }
156156 }
157157 } ) ;
@@ -173,8 +173,8 @@ describe('`after` hooks', () => {
173173
174174 service . hooks ( {
175175 after : {
176- update ( hook , next ) {
177- next ( new Error ( 'This did not work' ) ) ;
176+ update ( ) {
177+ throw new Error ( 'This did not work' ) ;
178178 }
179179 }
180180 } ) ;
@@ -221,19 +221,18 @@ describe('`after` hooks', () => {
221221
222222 service . hooks ( {
223223 after : {
224- create ( hook , next ) {
224+ create ( hook ) {
225225 hook . result . some = 'thing' ;
226- next ( ) ;
226+
227+ return hook ;
227228 }
228229 }
229230 } ) ;
230231
231232 service . hooks ( {
232233 after : {
233- create ( hook , next ) {
234+ create ( hook ) {
234235 hook . result . other = 'stuff' ;
235-
236- next ( ) ;
237236 }
238237 }
239238 } ) ;
@@ -260,14 +259,15 @@ describe('`after` hooks', () => {
260259 service . hooks ( {
261260 after : {
262261 create : [
263- function ( hook , next ) {
262+ function ( hook ) {
264263 hook . result . some = 'thing' ;
265- next ( ) ;
264+
265+ return hook ;
266266 } ,
267- function ( hook , next ) {
267+ function ( hook ) {
268268 hook . result . other = 'stuff' ;
269269
270- next ( ) ;
270+ return hook ;
271271 }
272272 ]
273273 }
@@ -293,23 +293,26 @@ describe('`after` hooks', () => {
293293
294294 service . hooks ( {
295295 after : {
296- get ( hook , next ) {
296+ get ( hook ) {
297297 hook . result . items = [ 'first' ] ;
298- next ( ) ;
298+
299+ return hook ;
299300 }
300301 }
301302 } ) ;
302303
303304 service . hooks ( {
304305 after : {
305306 get : [
306- function ( hook , next ) {
307+ function ( hook ) {
307308 hook . result . items . push ( 'second' ) ;
308- next ( ) ;
309+
310+ return hook ;
309311 } ,
310- function ( hook , next ) {
312+ function ( hook ) {
311313 hook . result . items . push ( 'third' ) ;
312- next ( ) ;
314+
315+ return hook ;
313316 }
314317 ]
315318 }
@@ -338,18 +341,20 @@ describe('`after` hooks', () => {
338341
339342 service
E593
. hooks ( {
340343 after : {
341- all ( hook , next ) {
344+ all ( hook ) {
342345 hook . result . afterAllObject = true ;
343- next ( ) ;
346+
347+ return hook ;
344348 }
345349 }
346350 } ) ;
347351
348352 service . hooks ( {
349353 after : [
350- function ( hook , next ) {
354+ function ( hook ) {
351355 hook . result . afterAllMethodArray = true ;
352- next ( ) ;
356+
357+ return hook ;
353358 }
354359 ]
355360 } ) ;
@@ -380,9 +385,10 @@ describe('`after` hooks', () => {
380385
381386 service . hooks ( {
382387 after : {
383- get ( hook , next ) {
388+ get ( hook ) {
384389 hook . result . test = this . number + 1 ;
385- next ( ) ;
390+
391+ return hook ;
386392 }
387393 }
388394 } ) ;
@@ -395,32 +401,5 @@ describe('`after` hooks', () => {
395401 } ) ;
396402 } ) ;
397403 } ) ;
398-
399- it ( 'can not call next() multiple times' , ( ) => {
400- const app = feathers ( ) . use ( '/dummy' , {
401- get ( id ) {
402- return Promise . resolve ( { id } ) ;
403- }
404- } ) ;
405-
406- const service = app . service ( 'dummy' ) ;
407-
408- service . hooks ( {
409- after : {
410- get : [
411- function ( hook , next ) {
412- next ( ) ;
413- } ,
414-
415- function ( hook , next ) {
416- next ( ) ;
417- next ( ) ;
418- }
419- ]
420- }
421- } ) ;
422-
423- return service . get ( 10 ) ;
424- } ) ;
425404 } ) ;
426405} ) ;
0 commit comments