Skip to content

Commit

Permalink
test: add coverage for AsyncResource constructor
Browse files Browse the repository at this point in the history
PR-URL: #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>
  • Loading branch information
gergelyke authored and addaleax committed Jun 10, 2017
1 parent d66d4fc commit f686f73
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/parallel/test-async-wrap-asyncresource-constructor.js
Original file line number Diff line number Diff line change
@@ -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$/);

0 comments on commit f686f73

Please sign in to comment.