mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
test: add coverage for AsyncResource constructor
PR-URL: https://github.com/nodejs/node/pull/13327 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
This commit is contained in:
1 parent
8d7f07f379
commit
52f358b531
1 file changed
+23
@@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
require('../common');
|
||||
|
||||
// This tests that AsyncResource throws an error if bad parameters are passed
|
||||
|
||||
const assert = require('assert');
|
||||
const AsyncResource = require('async_hooks').AsyncResource;
|
||||
|
||||
assert.throws(() => {
|
||||
return new AsyncResource();
|
||||
}, /^TypeError: type must be a string with length > 0$/);
|
||||
|
||||
assert.throws(() => {
|
||||
new AsyncResource('');
|
||||
}, /^TypeError: type must be a string with length > 0$/);
|
||||
|
||||
assert.throws(() => {
|
||||
new AsyncResource('type', -4);
|
||||
}, /^RangeError: triggerId must be an unsigned integer$/);
|
||||
|
||||
assert.throws(() => {
|
||||
new AsyncResource('type', Math.PI);
|
||||
}, /^RangeError: triggerId must be an unsigned integer$/);
|
||||
Reference in new issue
Block a user