UNPKG

662 BJavaScriptView Raw
1import { expect } from 'chai';
2import sinon from 'sinon';
3
4import tap from '../../../src/middleware/tap';
5
6describe('tap', () => {
7 it('should call the tap function', () => {
8 const next = sinon.spy();
9 const spy = sinon.spy();
10 const app = tap(spy)({ request: next });
11 const req = 1;
12 const res = 2;
13 app.request(req, res);
14 expect(spy).to.be.calledWith(req, res);
15 });
16
17 it('should continue the chain', () => {
18 const next = sinon.spy();
19 const spy = sinon.spy();
20 const app = tap(spy)({ request: next });
21 const req = 1;
22 const res = 2;
23 app.request(req, res);
24 expect(next).to.be.calledWith(req, res);
25 });
26});