Skip to content
Myr

req.acceptsLanguages.js

This file

Path

test/req.acceptsLanguages.js

57 lines · 1.4 KiB · JavaScript

Last changed by

Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b

History of this file

Take it

The walk stopped after 200 commits: lines older than 6aa4a45 point at it.

Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b

line 1why, one step back
1'use strict'

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 2–7why, one step back
2
3var express = require('../')4 , request = require('supertest');56describe('req', function(){7 describe('.acceptsLanguages', function(){

Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b

line 8why, one step back
8 it('should return language if accepted', function (done) {

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 9–10why, one step back
9 var app = express();
10

Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b

lines 11–16why, one step back
11 app.get('/', function (req, res) {
12 res.send({13 'en-us': req.acceptsLanguages('en-us'),14 en: req.acceptsLanguages('en')15 })16 })

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 17–18why, one step back
17
18 request(app)

Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b

lines 19–21why, one step back
19 .get('/')
20 .set('Accept-Language', 'en;q=.5, en-us')21 .expect(200, { 'en-us': 'en-us', en: 'en' }, done)

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 22–23why, one step back
22 })
23

Merge tag '4.14.1'Douglas Christopher Wilsonbefore adoptionbcbb9d5

line 24why, one step back
24 it('should be false if language not accepted', function(done){

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 25–26why, one step back
25 var app = express();
26

Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b

lines 27–31why, one step back
27 app.get('/', function (req, res) {
28 res.send({29 es: req.acceptsLanguages('es')30 })31 })

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 32–33why, one step back
32
33 request(app)

Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b

lines 34–36why, one step back
34 .get('/')
35 .set('Accept-Language', 'en;q=.5, en-us')36 .expect(200, { es: false }, done)

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 37–39why, one step back
37 })
3839 describe('when Accept-Language is not present', function(){

Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b

line 40why, one step back
40 it('should always return language', function (done) {

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 41–42why, one step back
41 var app = express();
42

Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b

lines 43–49why, one step back
43 app.get('/', function (req, res) {
44 res.send({45 en: req.acceptsLanguages('en'),46 es: req.acceptsLanguages('es'),47 jp: req.acceptsLanguages('jp')48 })49 })

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 50–51why, one step back
50
51 request(app)

Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b

lines 52–53why, one step back
52 .get('/')
53 .expect(200, { en: 'en', es: 'es', jp: 'jp' }, done)

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 54–57why, one step back
54 })
55 })56 })57})