Skip to content

Commit

Permalink
chore: addressed PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
bizob2828 committed Oct 4, 2024
1 parent da9f043 commit 3053a22
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 24 deletions.
File renamed without changes.
4 changes: 2 additions & 2 deletions test/lib/promises/transaction-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
const helper = require('../agent_helper')
const { tspl } = require('@matteo.collina/tspl')
const { checkTransaction } = require('./helpers')
const initFixtures = require('./fixtures')
const initSharedTests = require('./common-tests')

module.exports = async function runTests({ t, agent, Promise, library }) {
const performTests = initFixtures({ t, agent, Promise })
const performTests = initSharedTests({ t, agent, Promise })
/* eslint-disable no-shadow, brace-style */
if (library) {
await performTests(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ function testAsCallbackBehavior(methodName) {
id(inCallbackTransaction),
name + 'should have the same transaction inside the success callback'
)
plan.ok(!err, name + 'should not have an error')
plan.ok(!err)
plan.deepEqual(result, [1, 2, 3, name], name + 'should have the correct result value')
})
.then(function () {
Expand Down Expand Up @@ -534,7 +534,7 @@ function testCatchBehavior(methodName) {
count: 2,
testFunc: function asCallbackTest({ plan, name, promise }) {
return promise[methodName](function (err) {
plan.ok(!err, name + 'should not go into ' + methodName + ' from a resolved promise')
plan.ok(!err)
})
.then(function () {
throw new Error('Promise#' + methodName + ' test error')
Expand Down
22 changes: 5 additions & 17 deletions test/versioned/bluebird/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ const { runMultiple } = require('../../lib/promises/helpers')
const { tspl } = require('@matteo.collina/tspl')
const symbols = require('../../../lib/symbols')
const helper = require('../../lib/agent_helper')
const util = require('util')
const setImmediatePromisified = util.promisify(setImmediate)
const { setImmediate } = require('timers/promises')

async function beforeEach(ctx) {
ctx.nr = {}
Expand All @@ -23,14 +22,14 @@ async function beforeEach(ctx) {
}
}, 25)

await setImmediatePromisified()
await setImmediate()
}

async function afterEach(ctx) {
helper.unloadAgent(ctx.nr.agent)
clearInterval(ctx.nr.interval)

await setImmediatePromisified()
await setImmediate()
}

function id(tx) {
Expand Down Expand Up @@ -81,12 +80,7 @@ function testPromiseMethod({ t, count, factory, end }) {
testInTransaction()
},
function (err) {
if (err) {
/* eslint-disable no-console */
console.log(err.stack)
/* eslint-enable no-console */
}
plan.ok(!err, name + 'should not result in error')
plan.ok(!err)
end()
}
)
Expand Down Expand Up @@ -114,13 +108,7 @@ function testPromiseMethod({ t, count, factory, end }) {
)
},
function (err) {
if (err) {
/* eslint-disable no-console */
console.log(err)
console.log(err.stack)
/* eslint-enable no-console */
}
plan.ok(!err, name + 'should not result in error')
plan.ok(!err)
}
)
.finally(cb)
Expand Down
6 changes: 3 additions & 3 deletions test/versioned/bluebird/methods.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const {
testTryBehavior,
testPromiseClassCastMethod,
testPromiseInstanceCastMethod
} = require('./fixtures')
} = require('./common-tests')
const {
addTask,
afterEach,
Expand Down Expand Up @@ -1179,7 +1179,7 @@ test('Promise#error', async function (t) {
testFunc: function ({ plan, promise, name }) {
return promise
.error(function (err) {
plan.ok(!err, name + 'should not go into error from a resolved promise')
plan.ok(!err)
})
.then(function () {
throw new OperationalError('Promise#error test error')
Expand Down Expand Up @@ -1805,7 +1805,7 @@ test('Promise#timeout', async function (t) {
start = Date.now()
},
function (err) {
plan.ok(!err, name + 'should not have timed out')
plan.ok(!err)
}
)
.delay(1000, 'never see me')
Expand Down

0 comments on commit 3053a22

Please sign in to comment.