2015-10-20 12:18:15 -06:00
|
|
|
'use strict';
|
|
|
|
|
2015-12-23 16:02:12 -08:00
|
|
|
require('../common');
|
2015-10-20 12:18:15 -06:00
|
|
|
const assert = require('assert');
|
|
|
|
const async_wrap = process.binding('async_wrap');
|
|
|
|
|
|
|
|
assert.throws(function() {
|
|
|
|
async_wrap.setupHooks(null);
|
2016-02-22 16:34:35 -07:00
|
|
|
}, /first argument must be an object/);
|
2015-10-20 12:18:15 -06:00
|
|
|
|
2016-08-20 21:37:59 +08:00
|
|
|
assert.throws(function() {
|
|
|
|
async_wrap.setupHooks({});
|
|
|
|
}, /init callback must be a function/);
|
|
|
|
|
2015-10-20 12:18:15 -06:00
|
|
|
assert.throws(function() {
|
|
|
|
async_wrap.enable();
|
|
|
|
}, /init callback is not assigned to a function/);
|
|
|
|
|
|
|
|
// Should not throw
|
2016-02-22 16:34:35 -07:00
|
|
|
async_wrap.setupHooks({ init: () => {} });
|
2015-10-20 12:18:15 -06:00
|
|
|
async_wrap.enable();
|
|
|
|
|
|
|
|
assert.throws(function() {
|
|
|
|
async_wrap.setupHooks(() => {});
|
|
|
|
}, /hooks should not be set while also enabled/);
|