11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci// Flags: --expose-internals
31cb0ef41Sopenharmony_ci
41cb0ef41Sopenharmony_ciconst common = require('../common');
51cb0ef41Sopenharmony_ciconst assert = require('assert');
61cb0ef41Sopenharmony_ciconst async_hooks = require('internal/async_hooks');
71cb0ef41Sopenharmony_ciconst initHooks = require('./init-hooks');
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ciconst expectedId = async_hooks.newAsyncId();
101cb0ef41Sopenharmony_ciconst expectedTriggerId = async_hooks.newAsyncId();
111cb0ef41Sopenharmony_ciconst expectedType = 'test_emit_init_type';
121cb0ef41Sopenharmony_ciconst expectedResource = { key: 'test_emit_init_resource' };
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ciconst hooks1 = initHooks({
151cb0ef41Sopenharmony_ci  oninit: common.mustCall((id, type, triggerAsyncId, resource) => {
161cb0ef41Sopenharmony_ci    assert.strictEqual(id, expectedId);
171cb0ef41Sopenharmony_ci    assert.strictEqual(type, expectedType);
181cb0ef41Sopenharmony_ci    assert.strictEqual(triggerAsyncId, expectedTriggerId);
191cb0ef41Sopenharmony_ci    assert.strictEqual(resource.key, expectedResource.key);
201cb0ef41Sopenharmony_ci  }),
211cb0ef41Sopenharmony_ci});
221cb0ef41Sopenharmony_ci
231cb0ef41Sopenharmony_cihooks1.enable();
241cb0ef41Sopenharmony_ci
251cb0ef41Sopenharmony_ciasync_hooks.emitInit(expectedId, expectedType, expectedTriggerId,
261cb0ef41Sopenharmony_ci                     expectedResource);
271cb0ef41Sopenharmony_ci
281cb0ef41Sopenharmony_cihooks1.disable();
291cb0ef41Sopenharmony_ci
301cb0ef41Sopenharmony_ciinitHooks({
311cb0ef41Sopenharmony_ci  oninit: common.mustCall((id, type, triggerAsyncId, resource) => {
321cb0ef41Sopenharmony_ci    assert.strictEqual(id, expectedId);
331cb0ef41Sopenharmony_ci    assert.strictEqual(type, expectedType);
341cb0ef41Sopenharmony_ci    assert.notStrictEqual(triggerAsyncId, expectedTriggerId);
351cb0ef41Sopenharmony_ci    assert.strictEqual(resource.key, expectedResource.key);
361cb0ef41Sopenharmony_ci  }),
371cb0ef41Sopenharmony_ci}).enable();
381cb0ef41Sopenharmony_ci
391cb0ef41Sopenharmony_ciasync_hooks.emitInit(expectedId, expectedType, null, expectedResource);
40