eugef / node-mocks-http

Mock 'http' objects for testing Express,js, Next.js and Koa routing functions
Other
757 stars 134 forks source link

Support Express acceptsLanguages HTTP Accept-Language Header #187

Closed AndyOGo closed 5 years ago

AndyOGo commented 5 years ago

Express Request provides acceptsLanguages(). https://github.com/expressjs/express/blob/e1b45ebd050b6f06aa38cda5aaf0c21708b0c71e/lib/request.js#L179-L182

I want to unit test my configured express-locale middleware, with uses above method, but it doesn't work.

const req = httpMocks.createRequest({
      headers: {
        'Accept-Language': `${language}-${region}`,
      },
    });

The accepts module supports languages (which is utilized by express)

AndyOGo commented 5 years ago

Also acceptsCharsets and acceptsEncoding of express are missing

AndyOGo commented 5 years ago

duplicate of #128