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 fileTake it
The walk stopped after 200 commits: lines older than 454c4b2 point at it.
Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b
line 1why, one step back1'use strict'Merge tag '3.15.2'Douglas Christopher Wilsonbefore adoption454c4b2
lines 2–7why, one step back23var 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 back8 it('should return language if accepted', function (done) {Merge tag '3.15.2'Douglas Christopher Wilsonbefore adoption454c4b2
lines 9–10why, one step back9 var app = express();10Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b
lines 11–16why, one step back11 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.15.2'Douglas Christopher Wilsonbefore adoption454c4b2
lines 17–18why, one step back1718 request(app)Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b
lines 19–21why, one step back19 .get('/')20 .set('Accept-Language', 'en;q=.5, en-us')21 .expect(200, { 'en-us': 'en-us', en: 'en' }, done)Merge tag '3.15.2'Douglas Christopher Wilsonbefore adoption454c4b2
lines 22–23why, one step back22 })23Merge tag '4.14.1'Douglas Christopher Wilsonbefore adoptionbcbb9d5
line 24why, one step back24 it('should be false if language not accepted', function(done){Merge tag '3.15.2'Douglas Christopher Wilsonbefore adoption454c4b2
lines 25–26why, one step back25 var app = express();26Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b
lines 27–31why, one step back27 app.get('/', function (req, res) {28 res.send({29 es: req.acceptsLanguages('es')30 })31 })Merge tag '3.15.2'Douglas Christopher Wilsonbefore adoption454c4b2
lines 32–33why, one step back3233 request(app)Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b
lines 34–36why, one step back34 .get('/')35 .set('Accept-Language', 'en;q=.5, en-us')36 .expect(200, { es: false }, done)Merge tag '3.15.2'Douglas Christopher Wilsonbefore adoption454c4b2
lines 37–39why, one step back37 })3839 describe('when Accept-Language is not present', function(){Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b
line 40why, one step back40 it('should always return language', function (done) {Merge tag '3.15.2'Douglas Christopher Wilsonbefore adoption454c4b2
lines 41–42why, one step back41 var app = express();42Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b
lines 43–49why, one step back43 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.15.2'Douglas Christopher Wilsonbefore adoption454c4b2
lines 50–51why, one step back5051 request(app)Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b
lines 52–53why, one step back52 .get('/')53 .expect(200, { en: 'en', es: 'es', jp: 'jp' }, done)Merge tag '3.15.2'Douglas Christopher Wilsonbefore adoption454c4b2
lines 54–57why, one step back54 })55 })56 })57})