(binding)
| 18 | module.exports = require('./common').runTest(test); |
| 19 | |
| 20 | function test (binding) { |
| 21 | if (!checkAsyncHooks()) { return; } |
| 22 | |
| 23 | let id; |
| 24 | let insideHook = false; |
| 25 | const hook = asyncHooks.createHook({ |
| 26 | init (asyncId, type, triggerAsyncId, resource) { |
| 27 | if (id === undefined && (type === 'callback_scope_test' || type === 'existing_callback_scope_test')) { |
| 28 | id = asyncId; |
| 29 | } |
| 30 | }, |
| 31 | before (asyncId) { |
| 32 | if (asyncId === id) { insideHook = true; } |
| 33 | }, |
| 34 | after (asyncId) { |
| 35 | if (asyncId === id) { insideHook = false; } |
| 36 | } |
| 37 | }).enable(); |
| 38 | |
| 39 | return new Promise(resolve => { |
| 40 | binding.callbackscope.runInCallbackScope(function () { |
| 41 | assert(insideHook); |
| 42 | binding.callbackscope.runInPreExistingCbScope(function () { |
| 43 | assert(insideHook); |
| 44 | hook.disable(); |
| 45 | resolve(); |
| 46 | }); |
| 47 | }); |
| 48 | }); |
| 49 | } |
nothing calls this directly
no test coverage detected