1 | import { expect } from 'chai';
|
2 | import sinon from 'sinon';
|
3 |
|
4 | import useragent from '../../../src/middleware/useragent';
|
5 |
|
6 | it('should assign an agent property to the request', () => {
|
7 | const spy = sinon.spy();
|
8 | const app = useragent()({ request: spy });
|
9 | app.request({ headers: {
|
10 | 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2)' +
|
11 | 'AppleWebKit/537.36 (KHTML, like Gecko)' +
|
12 | 'Chrome/47.0.2526.106 Safari/537.36',
|
13 | }}, {});
|
14 | expect(spy).to.be.calledWithMatch(req => !!req.agent);
|
15 | });
|