Skip to content

Commit

Permalink
test: Fixed @koa/router tests. path-to-regex differs between @koa/rou…
Browse files Browse the repository at this point in the history
…ter and koa-router now (#2587)
  • Loading branch information
bizob2828 authored Sep 18, 2024
1 parent a5a1526 commit 608dd98
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions test/versioned/koa/router-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ module.exports = (pkg) => {
t.test('should name and produce segments for matched wildcard path', (t) => {
const { agent, router, app } = t.context
let path = '(.*)'
if (semver.gte(pkgVersion, '13.0.1')) {
if (pkg === 'koa-router' && semver.gte(pkgVersion, '13.0.1')) {
path = '{*any}'
}
router.get(`/:first/${path}`, function firstMiddleware(ctx) {
Expand Down Expand Up @@ -347,15 +347,16 @@ module.exports = (pkg) => {
ctx.body = ' second'
})

const segmentTree = semver.gte(pkgVersion, '13.0.1')
? ['Nodejs/Middleware/Koa/terminalMiddleware//:second']
: [
'Nodejs/Middleware/Koa/secondMiddleware//:first',
[
'Nodejs/Middleware/Koa/secondMiddleware//:second',
['Nodejs/Middleware/Koa/terminalMiddleware//:second']
const segmentTree =
pkg === 'koa-router' && semver.gte(pkgVersion, '13.0.1')
? ['Nodejs/Middleware/Koa/terminalMiddleware//:second']
: [
'Nodejs/Middleware/Koa/secondMiddleware//:first',
[
'Nodejs/Middleware/Koa/secondMiddleware//:second',
['Nodejs/Middleware/Koa/terminalMiddleware//:second']
]
]
]
app.use(router.routes())
agent.on('transactionFinished', (tx) => {
t.assertSegments(tx.trace.root, [
Expand Down

0 comments on commit 608dd98

Please sign in to comment.