Skip to content
Myr

req.accepted.js

This file

Path

test/req.accepted.js

37 lines · 889 bytes · JavaScript

Last changed by

testsTJ Holowaychukbefore adoption2adf020

History of this file

Take it

Added req.acceptedTJ Holowaychukbefore adoptiona8fd8cb

lines 1–6why, one step back
1
2var express = require('../')3 , request = require('./support/http');45describe('req', function(){6 describe('.accepted', function(){

Added req.acceptedLanguagesTJ Holowaychukbefore adoptione8c3736

line 7why, one step back
7 it('should return an array of accepted media types', function(done){

Added req.acceptedTJ Holowaychukbefore adoptiona8fd8cb

lines 8–18why, one step back
8 var app = express();
910 app.use(function(req, res){11 req.accepted[0].value.should.equal('application/json');12 req.accepted[1].value.should.equal('text/html');13 res.end();14 });1516 request(app)17 .get('/')18 .set('Accept', 'text/html;q=.5, application/json')

testsTJ Holowaychukbefore adoption2adf020

line 19why, one step back
19 .expect(200, done);

Added req.acceptedTJ Holowaychukbefore adoptiona8fd8cb

lines 20–32why, one step back
20 })
2122 describe('when Accept is not present', function(){23 it('should default to []', function(done){24 var app = express();2526 app.use(function(req, res){27 req.accepted.should.have.length(0);28 res.end();29 });3031 request(app)32 .get('/')

testsTJ Holowaychukbefore adoption2adf020

line 33why, one step back
33 .expect(200, done);

Added req.acceptedTJ Holowaychukbefore adoptiona8fd8cb

lines 34–37why, one step back
34 })
35 })36 })37})