| 64 | } |
| 65 | |
| 66 | async function makeCallbackWithResource (binding) { |
| 67 | const hooks = installAsyncHooksForTest('async_context_test'); |
| 68 | const triggerAsyncId = asyncHooks.executionAsyncId(); |
| 69 | await new Promise((resolve, reject) => { |
| 70 | binding.asynccontext.makeCallback(common.mustCall(), { foo: 'foo' }); |
| 71 | hooks.then(actual => { |
| 72 | assert.deepStrictEqual(actual, [ |
| 73 | { |
| 74 | eventName: 'init', |
| 75 | type: 'async_context_test', |
| 76 | triggerAsyncId, |
| 77 | resource: { foo: 'foo' } |
| 78 | }, |
| 79 | { eventName: 'before' }, |
| 80 | { eventName: 'after' }, |
| 81 | { eventName: 'destroy' } |
| 82 | ]); |
| 83 | }).catch(common.mustNotCall()); |
| 84 | resolve(); |
| 85 | }); |
| 86 | } |
| 87 | |
| 88 | async function makeCallbackWithoutResource (binding) { |
| 89 | const hooks = installAsyncHooksForTest('async_context_no_res_test'); |