3 var express = require('../')
4 , request = require('supertest');
6 describe('req', function(){
7 describe('.acceptsLanguages', function(){
8 it('should return language if accepted', function (done) {
11 app.get('/', function (req, res) {
13 'en-us': req.acceptsLanguages('en-us'),
14 en: req.acceptsLanguages('en')
20 .set('Accept-Language', 'en;q=.5, en-us')
21 .expect(200, { 'en-us': 'en-us', en: 'en' }, done)
24 it('should be false if language not accepted', function(done){
27 app.get('/', function (req, res) {
29 es: req.acceptsLanguages('es')
35 .set('Accept-Language', 'en;q=.5, en-us')
36 .expect(200, { es: false }, done)
39 describe('when Accept-Language is not present', function(){
40 it('should always return language', function (done) {
43 app.get('/', function (req, res) {
45 en: req.acceptsLanguages('en'),
46 es: req.acceptsLanguages('es'),
47 jp: req.acceptsLanguages('jp')
53 .expect(200, { en: 'en', es: 'es', jp: 'jp' }, done)