UNPKG

be-framework

Version:

BE is a framework for supercharging your BotEngine bots

28 lines (22 loc) 627 B
const httpMocks = require('node-mocks-http'); const verify = require('./verify'); const challenge = 'challenge'; const token = 'token'; describe('verify', () => { test('checks token', () => { const req = httpMocks.createRequest({ method: 'POST', url: `/?token=invalid`, }); const app = verify(token)(() => 'works'); expect(() => app(req)).toThrow(); }); test('responds to challenge', async () => { const req = httpMocks.createRequest({ method: 'GET', url: `/?challenge=${challenge}&token=${token}`, }); const app = verify(token)(() => 'works'); expect(app(req)).toEqual(challenge); }); });