Skip to content

Commit

Permalink
test: add in test to support #1107
Browse files Browse the repository at this point in the history
  • Loading branch information
willfarrell committed Sep 25, 2023
1 parent 6a9e0fc commit 341dd4a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions packages/http-router/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,31 @@ test('It should run middleware that are part of route handler', async (t) => {
t.true(response)
})

test('It should not run middleware that are part of another route handler', async (t) => {
const event = {
httpMethod: 'GET',
path: '/'
}
let success = true
const handler = httpRouter([
{
method: 'GET',
path: '/',
handler: middy(() => true)
},
{
method: 'GET',
path: '/middy',
handler: middy(() => false).before((request) => {
success = false
})
}
])
const response = await handler(event, context)
t.true(response)
t.true(success)
})

test('It should run middleware part of router', async (t) => {
const event = {
httpMethod: 'GET',
Expand Down

0 comments on commit 341dd4a

Please sign in to comment.