()
| 63 | tick(1, common.mustCall(tick1)); |
| 64 | |
| 65 | function tick1() { |
| 66 | checkInvocations(alcazares, { init: 1, before: 2, after: 2, destroy: 1 }, |
| 67 | 'alcazares emitted destroy'); |
| 68 | |
| 69 | // The below shows that we can pass any number as a trigger id |
| 70 | const pobTriggerId = 111; |
| 71 | const pobEvent = new AsyncResource('poblado', pobTriggerId); |
| 72 | const pobladoActivities = hooks.activitiesOfTypes([ 'poblado' ]); |
| 73 | const poblado = pobladoActivities[0]; |
| 74 | assert.strictEqual(poblado.type, 'poblado'); |
| 75 | assert.strictEqual(typeof poblado.uid, 'number'); |
| 76 | assert.strictEqual(poblado.triggerAsyncId, pobTriggerId); |
| 77 | checkInvocations(poblado, { init: 1 }, 'poblado constructed'); |
| 78 | pobEvent.runInAsyncScope(() => { |
| 79 | checkInvocations(poblado, { init: 1, before: 1 }, |
| 80 | 'poblado emitted before'); |
| 81 | }); |
| 82 | |
| 83 | checkInvocations(poblado, { init: 1, before: 1, after: 1 }, |
| 84 | 'poblado emitted after'); |
| 85 | |
| 86 | // After we disable the hooks we shouldn't receive any events anymore |
| 87 | hooks.disable(); |
| 88 | alcaEvent.emitDestroy(); |
| 89 | tick(1, common.mustCall(tick2)); |
| 90 | |
| 91 | function tick2() { |
| 92 | checkInvocations( |
| 93 | alcazares, { init: 1, before: 2, after: 2, destroy: 1 }, |
| 94 | 'alcazares emitted destroy a second time after hooks disabled'); |
| 95 | pobEvent.emitDestroy(); |
| 96 | tick(1, common.mustCall(tick3)); |
| 97 | } |
| 98 | |
| 99 | function tick3() { |
| 100 | checkInvocations(poblado, { init: 1, before: 1, after: 1 }, |
| 101 | 'poblado emitted destroy after hooks disabled'); |
| 102 | } |
| 103 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…