UNPKG

448 BJavaScriptView Raw
1import { expect } from 'chai';
2import sinon from 'sinon';
3
4import locale from '../../../src/middleware/locale';
5
6it('should assign a locale property to the request', () => {
7 const spy = sinon.spy();
8 const app = locale({
9 locales: [ 'en-US', 'en-GB' ],
10 })({ request: spy });
11 app.request({
12 headers: {
13 'accept-language': 'en-GB,en-US;q=0.8,en;q=0.6',
14 },
15 }, {});
16 expect(spy).to.be.calledWithMatch(req => !!req.locale);
17});