Skip to content

Commit

Permalink
Nit: comments and change var names
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderleegs committed Jan 11, 2023
1 parent f717000 commit d6c1b3e
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/integration/NotificationOnEditHandler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,30 +73,28 @@ const notificationsHandler = new NotificationOnEditHandler({
})

// Set up express with defaults and use the router under test
const subrouter = express()
const subSubrouter = express()
subSubrouter.get("/:siteName/test", async (req, res, next) =>
const router = express()
const dummySubrouter = express()
dummySubrouter.get("/:siteName/test", async (req, res, next) =>
// Dummy subrouter
next()
)
subrouter.use(subSubrouter)
router.use(dummySubrouter)

// We handle the test slightly differently - jest interprets the end of the test as when the response is sent,
// but we normally create a notification after this response, due to the position of the middleware
// the solution to get tests working is to send a response only after the notification middleware
subrouter.use(async (req, res, next) => {
router.use(async (req, res, next) => {
// Inserts notification handler after all other subrouters
// Needs to be awaited so jest doesn't exit prematurely upon receiving response status
await notificationsHandler.createNotification(req as any, res as any, next)
res.status(200).send(200)
})
const userSessionData = new UserSessionData({
isomerUserId: mockIsomerUserId,
email: mockEmail,
})
const app = generateRouterForUserWithSite(
subrouter,
userSessionData,
mockSiteName
)
const app = generateRouterForUserWithSite(router, userSessionData, mockSiteName)

describe("Notifications Router", () => {
const mockAdditionalUserId = "2"
Expand Down

0 comments on commit d6c1b3e

Please sign in to comment.