serverless-docker
Version:
This is a proof of concept to see if we can replicate Amazon API Gateway using docker images to run lambda
27 lines (19 loc) • 663 B
JavaScript
const customAuthorizer = {
authorize: jest.fn(),
}
jest.mock('./custom-authorizer', () => customAuthorizer)
const authorizer = require('./index')
describe('authorizer', () => {
beforeEach(() => {
customAuthorizer.authorize.mockClear()
})
it('should invoke custom authorizer', () => {
const context = {}
const authorizationToken = 'Bearer token'
authorizer.authorize(context, authorizationToken)
expect(customAuthorizer.authorize.mock.calls.length).toBe(1)
expect(customAuthorizer.authorize.mock.calls[0][0]).toBe(context)
expect(customAuthorizer.authorize.mock.calls[0][1]).toBe(authorizationToken)
})
})