Skip to content

Commit

Permalink
Merge branch 'main' into made-with
Browse files Browse the repository at this point in the history
  • Loading branch information
JHWelch authored Oct 20, 2023
2 parents 9fda49d + e3ede16 commit c389766
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
15 changes: 6 additions & 9 deletions __tests__/controllers/redirectController.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import RedirectController from '../../src/controllers/redirectController'
import { beforeEach, describe, expect, it } from '@jest/globals'
import { beforeEach, expect, it } from '@jest/globals'
import { getMockReq, getMockRes } from '@jest-mock/express'

const { res, mockClear } = getMockRes()
Expand All @@ -8,13 +8,10 @@ beforeEach(() => {
mockClear()
})

describe('sep21', () => {
it('should return a redirect to notion', async () => {
const req = getMockReq()
it('can redirect to a given url', () => {
const req = getMockReq()
const url = 'https://example.com'

await RedirectController.sep21(req, res)

expect(res.redirect)
.toHaveBeenCalledWith(RedirectController.sep21Url)
})
RedirectController.redirect(req, res, url)
expect(res.redirect).toHaveBeenCalledWith(url)
})
13 changes: 6 additions & 7 deletions src/controllers/redirectController.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { type Request, type Response } from 'express'

export default class RedirectController {
static PATHS = {
sep21: '/sep21',
}
static sep21Url = 'https://ginger-flood-c72.notion.site/The-2023-Celebration-of-Rachel-s-32nd-Birthday-Also-Known-As-Halloween-in-sepember-a17c5537f8594c30bb301a48c988f7ec'

static async sep21 (_req: Request, res: Response): Promise<void> {
res.redirect(RedirectController.sep21Url)
static async redirect (
_req: Request,
res: Response,
url: string
): Promise<void> {
res.redirect(url)
}
}
2 changes: 0 additions & 2 deletions src/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import FirestoreAdapter from './data/firestore/firestoreAdapter.js'
import TmdbAdapter from './data/tmdb/tmdbAdapter.js'
import RsvpController from './controllers/rsvpController.js'
import HealthCheckController from './controllers/healthCheckController.js'
import RedirectController from './controllers/redirectController.js'

export function registerRoutes (
express: Express,
Expand Down Expand Up @@ -62,7 +61,6 @@ function routes (
CacheController.PATHS.emailTemplates,
cacheController.cacheEmailTemplates.bind(cacheController)
),
new Route(RedirectController.PATHS.sep21, RedirectController.sep21),
]
}

Expand Down

0 comments on commit c389766

Please sign in to comment.