Skip to content

Commit a491fef

Browse files
committed
test: remove async hook workaround and use node prefixes
1 parent f830de3 commit a491fef

File tree

1 file changed

+13
-26
lines changed

1 file changed

+13
-26
lines changed

test/test.js

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
2-
var assert = require('assert')
3-
var asyncHooks = tryRequire('async_hooks')
4-
var http = require('http')
5-
var net = require('net')
6-
var onFinished = require('..')
7-
8-
var describeAsyncHooks = typeof asyncHooks.AsyncLocalStorage === 'function'
9-
? describe
10-
: describe.skip
1+
const assert = require('node:assert')
2+
const { AsyncLocalStorage } = require('node:async_hooks')
3+
const http = require('node:http')
4+
const net = require('node:net')
5+
const onFinished = require('..')
116

127
describe('onFinished(res, listener)', function () {
138
it('should invoke listener given an unknown object', function (done) {
@@ -49,9 +44,9 @@ describe('onFinished(res, listener)', function () {
4944
sendGet(server)
5045
})
5146

52-
describeAsyncHooks('when async local storage', function () {
47+
describe('when async local storage', function () {
5348
it('should presist store in callback', function (done) {
54-
var asyncLocalStorage = new asyncHooks.AsyncLocalStorage()
49+
var asyncLocalStorage = new AsyncLocalStorage()
5550
var store = { foo: 'bar' }
5651

5752
var server = http.createServer(function (req, res) {
@@ -71,9 +66,9 @@ describe('onFinished(res, listener)', function () {
7166
})
7267
})
7368

74-
describeAsyncHooks('when async local storage', function () {
69+
describe('when async local storage', function () {
7570
it('should presist store in callback', function (done) {
76-
var asyncLocalStorage = new asyncHooks.AsyncLocalStorage()
71+
var asyncLocalStorage = new AsyncLocalStorage()
7772
var store = { foo: 'bar' }
7873

7974
var server = http.createServer(function (req, res) {
@@ -445,9 +440,9 @@ describe('onFinished(req, listener)', function () {
445440
sendGet(server)
446441
})
447442

448-
describeAsyncHooks('when async local storage', function () {
443+
describe('when async local storage', function () {
449444
it('should presist store in callback', function (done) {
450-
var asyncLocalStorage = new asyncHooks.AsyncLocalStorage()
445+
var asyncLocalStorage = new AsyncLocalStorage()
451446
var store = { foo: 'bar' }
452447

453448
var server = http.createServer(function (req, res) {
@@ -468,9 +463,9 @@ describe('onFinished(req, listener)', function () {
468463
})
469464
})
470465

471-
describeAsyncHooks('when async local storage', function () {
466+
describe('when async local storage', function () {
472467
it('should presist store in callback', function (done) {
473-
var asyncLocalStorage = new asyncHooks.AsyncLocalStorage()
468+
var asyncLocalStorage = new AsyncLocalStorage()
474469
var store = { foo: 'bar' }
475470

476471
var server = http.createServer(function (req, res) {
@@ -1159,14 +1154,6 @@ function sendGet (server) {
11591154
})
11601155
}
11611156

1162-
function tryRequire (name) {
1163-
try {
1164-
return require(name)
1165-
} catch (e) {
1166-
return {}
1167-
}
1168-
}
1169-
11701157
function writeRequest (socket, chunked) {
11711158
socket.write('GET / HTTP/1.1\r\n')
11721159
socket.write('Host: localhost\r\n')

0 commit comments

Comments
 (0)