@@ -66,6 +66,14 @@ function test(binding) {
6666 assert . strictEqual ( typeof this , 'object' ) ;
6767 assert . strictEqual ( this . data , 'test data' ) ;
6868 } , 'test data' ) ;
69+
70+ binding . asyncworker . doWorkWithResult ( true , { } , function ( succeed , succeedString ) {
71+ assert ( arguments . length == 2 ) ;
72+ assert ( succeed ) ;
73+ assert ( succeedString == "ok" ) ;
74+ assert . strictEqual ( typeof this , 'object' ) ;
75+ assert . strictEqual ( this . data , 'test data' ) ;
76+ } , 'test data' ) ;
6977 return ;
7078 }
7179
@@ -91,6 +99,30 @@ function test(binding) {
9199 } ) . catch ( common . mustNotCall ( ) ) ;
92100 }
93101
102+ {
103+ const hooks = installAsyncHooksForTest ( ) ;
104+ const triggerAsyncId = async_hooks . executionAsyncId ( ) ;
105+ binding . asyncworker . doWorkWithResult ( true , { foo : 'foo' } , function ( succeed , succeedString ) {
106+ assert ( arguments . length == 2 ) ;
107+ assert ( succeed ) ;
108+ assert ( succeedString == "ok" ) ;
109+ assert . strictEqual ( typeof this , 'object' ) ;
110+ assert . strictEqual ( this . data , 'test data' ) ;
111+ } , 'test data' ) ;
112+
113+ hooks . then ( actual => {
114+ assert . deepStrictEqual ( actual , [
115+ { eventName : 'init' ,
116+ type : 'TestResource' ,
117+ triggerAsyncId : triggerAsyncId ,
118+ resource : { foo : 'foo' } } ,
119+ { eventName : 'before' } ,
120+ { eventName : 'after' } ,
121+ { eventName : 'destroy' }
122+ ] ) ;
123+ } ) . catch ( common . mustNotCall ( ) ) ;
124+ }
125+
94126 {
95127 const hooks = installAsyncHooksForTest ( ) ;
96128 const triggerAsyncId = async_hooks . executionAsyncId ( ) ;
0 commit comments