xref: /third_party/node/test/parallel/test-async-wrap-constructor.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ci// This tests that using falsy values in createHook throws an error.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_cirequire('../common');
61cb0ef41Sopenharmony_ciconst assert = require('assert');
71cb0ef41Sopenharmony_ciconst async_hooks = require('async_hooks');
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ci[0, 1, false, true, null, 'hello'].forEach((badArg) => {
101cb0ef41Sopenharmony_ci  const hookNames = ['init', 'before', 'after', 'destroy', 'promiseResolve'];
111cb0ef41Sopenharmony_ci  hookNames.forEach((field) => {
121cb0ef41Sopenharmony_ci    assert.throws(() => {
131cb0ef41Sopenharmony_ci      async_hooks.createHook({ [field]: badArg });
141cb0ef41Sopenharmony_ci    }, {
151cb0ef41Sopenharmony_ci      code: 'ERR_ASYNC_CALLBACK',
161cb0ef41Sopenharmony_ci      name: 'TypeError',
171cb0ef41Sopenharmony_ci      message: `hook.${field} must be a function`
181cb0ef41Sopenharmony_ci    });
191cb0ef41Sopenharmony_ci  });
201cb0ef41Sopenharmony_ci});
21

Indexes created Thu Nov 07 10:32:03 CST 2024