Created
December 6, 2018 21:25
-
-
Save fforres/43fd55937d4292c312197fd5f12077e3 to your computer and use it in GitHub Desktop.
Middleware
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'jest' | |
import { enrichment, IEnrichmentRequest } from '../../src/middlewares/enrichment' | |
import { mockReq, mockRes } from 'sinon-express-mock' | |
import * as sinon from 'sinon' | |
const enrichmentMiddleware = enrichment() | |
jest.mock('../../src/middlewares/enrichment/api.ts') | |
let req: IEnrichmentRequest | |
let res | |
let next: sinon.SinonSpy | |
describe(`Enrichment Middleware`, () => { | |
beforeEach(() => { | |
req = mockReq({ | |
cookies: {} | |
}) | |
res = mockRes() | |
next = sinon.fake() | |
}) | |
it('Should not cotinue if request path is /healthcheck', async () => { | |
// Override the "beforeEachMockReq" | |
req = mockReq({ | |
path: '/healthcheck', | |
cookies: {} | |
}) | |
await enrichmentMiddleware(req, res, next) | |
next.calledWith({ msg: 'internal health check skip reveal' }) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment