Skip to content

Commit f686f73

Browse files
gergelykeaddaleax
authored andcommitted
test: add coverage for AsyncResource constructor
PR-URL: #13327 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Trevor Norris <[email protected]>
1 parent d66d4fc commit f686f73

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
require('../common');
3+
4+
// This tests that AsyncResource throws an error if bad parameters are passed
5+
6+
const assert = require('assert');
7+
const AsyncResource = require('async_hooks').AsyncResource;
8+
9+
assert.throws(() => {
10+
return new AsyncResource();
11+
}, /^TypeError: type must be a string with length > 0$/);
12+
13+
assert.throws(() => {
14+
new AsyncResource('');
15+
}, /^TypeError: type must be a string with length > 0$/);
16+
17+
assert.throws(() => {
18+
new AsyncResource('type', -4);
19+
}, /^RangeError: triggerId must be an unsigned integer$/);
20+
21+
assert.throws(() => {
22+
new AsyncResource('type', Math.PI);
23+
}, /^RangeError: triggerId must be an unsigned integer$/);

0 commit comments

Comments
 (0)