Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: remove AsyncLocalStorage check #549

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 3 additions & 15 deletions test/json.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
'use strict'

var assert = require('assert')
var asyncHooks = tryRequire('async_hooks')
var AsyncLocalStorage = require('async_hooks').AsyncLocalStorage
var http = require('http')
var request = require('supertest')

var bodyParser = require('..')

var describeAsyncHooks = typeof asyncHooks.AsyncLocalStorage === 'function'
? describe
: describe.skip

describe('bodyParser.json()', function () {
it('should parse JSON', function (done) {
request(createServer())
Expand Down Expand Up @@ -511,13 +507,13 @@ describe('bodyParser.json()', function () {
})
})

describeAsyncHooks('async local storage', function () {
describe('async local storage', function () {
before(function () {
var jsonParser = bodyParser.json()
var store = { foo: 'bar' }

this.server = createServer(function (req, res, next) {
var asyncLocalStorage = new asyncHooks.AsyncLocalStorage()
var asyncLocalStorage = new AsyncLocalStorage()

asyncLocalStorage.run(store, function () {
jsonParser(req, res, function (err) {
Expand Down Expand Up @@ -761,11 +757,3 @@ function shouldContainInBody (str) {
'expected \'' + res.text + '\' to contain \'' + str + '\'')
}
}

function tryRequire (name) {
try {
return require(name)
} catch (e) {
return {}
}
}
18 changes: 3 additions & 15 deletions test/raw.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
'use strict'

var assert = require('assert')
var asyncHooks = tryRequire('async_hooks')
var AsyncLocalStorage = require('async_hooks').AsyncLocalStorage
var http = require('http')
var request = require('supertest')

var bodyParser = require('..')

var describeAsyncHooks = typeof asyncHooks.AsyncLocalStorage === 'function'
? describe
: describe.skip

describe('bodyParser.raw()', function () {
before(function () {
this.server = createServer()
Expand Down Expand Up @@ -329,13 +325,13 @@ describe('bodyParser.raw()', function () {
})
})

describeAsyncHooks('async local storage', function () {
describe('async local storage', function () {
before(function () {
var rawParser = bodyParser.raw()
var store = { foo: 'bar' }

this.server = createServer(function (req, res, next) {
var asyncLocalStorage = new asyncHooks.AsyncLocalStorage()
var asyncLocalStorage = new AsyncLocalStorage()

asyncLocalStorage.run(store, function () {
rawParser(req, res, function (err) {
Expand Down Expand Up @@ -502,11 +498,3 @@ function createServer (opts) {
})
})
}

function tryRequire (name) {
try {
return require(name)
} catch (e) {
return {}
}
}
18 changes: 3 additions & 15 deletions test/text.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
'use strict'

var assert = require('assert')
var asyncHooks = tryRequire('async_hooks')
var AsyncLocalStorage = require('async_hooks').AsyncLocalStorage
var http = require('http')
var request = require('supertest')

var bodyParser = require('..')

var describeAsyncHooks = typeof asyncHooks.AsyncLocalStorage === 'function'
? describe
: describe.skip

describe('bodyParser.text()', function () {
before(function () {
this.server = createServer()
Expand Down Expand Up @@ -370,13 +366,13 @@ describe('bodyParser.text()', function () {
})
})

describeAsyncHooks('async local storage', function () {
describe('async local storage', function () {
before(function () {
var textParser = bodyParser.text()
var store = { foo: 'bar' }

this.server = createServer(function (req, res, next) {
var asyncLocalStorage = new asyncHooks.AsyncLocalStorage()
var asyncLocalStorage = new AsyncLocalStorage()

asyncLocalStorage.run(store, function () {
textParser(req, res, function (err) {
Expand Down Expand Up @@ -565,11 +561,3 @@ function createServer (opts) {
})
})
}

function tryRequire (name) {
try {
return require(name)
} catch (e) {
return {}
}
}
18 changes: 3 additions & 15 deletions test/urlencoded.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
'use strict'

var assert = require('assert')
var asyncHooks = tryRequire('async_hooks')
var AsyncLocalStorage = require('async_hooks').AsyncLocalStorage
var http = require('http')
var request = require('supertest')

var bodyParser = require('..')

var describeAsyncHooks = typeof asyncHooks.AsyncLocalStorage === 'function'
? describe
: describe.skip

describe('bodyParser.urlencoded()', function () {
before(function () {
this.server = createServer()
Expand Down Expand Up @@ -755,13 +751,13 @@ describe('bodyParser.urlencoded()', function () {
})
})

describeAsyncHooks('async local storage', function () {
describe('async local storage', function () {
before(function () {
var urlencodedParser = bodyParser.urlencoded()
var store = { foo: 'bar' }

this.server = createServer(function (req, res, next) {
var asyncLocalStorage = new asyncHooks.AsyncLocalStorage()
var asyncLocalStorage = new AsyncLocalStorage()

asyncLocalStorage.run(store, function () {
urlencodedParser(req, res, function (err) {
Expand Down Expand Up @@ -968,11 +964,3 @@ function expectKeyCount (count) {
assert.strictEqual(Object.keys(JSON.parse(res.text)).length, count)
}
}

function tryRequire (name) {
try {
return require(name)
} catch (e) {
return {}
}
}