summaryrefslogtreecommitdiff
path: root/test/parallel/test-async-hooks-enable-disable.js
blob: b685c7123454dd002b8eae4ea6397b5666fcf449 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
'use strict';
const common = require('../common');
const assert = require('assert');
const async_hooks = require('async_hooks');

const hook = async_hooks.createHook({
  init: common.mustCall(() => {}, 1),
  before: common.mustNotCall(),
  after: common.mustNotCall(),
  destroy: common.mustNotCall()
});

assert.strictEqual(hook.enable(), hook);
assert.strictEqual(hook.enable(), hook);

setImmediate(common.mustCall());

assert.strictEqual(hook.disable(), hook);
assert.strictEqual(hook.disable(), hook);
assert.strictEqual(hook.disable(), hook);