Skip to content
Myr

req.accepts.js

This file

Path

test/req.accepts.js

45 lines · 1.0 KiB · JavaScript

Last changed by

mergedTj Holowaychukbefore adoption547d18c

History of this file

Take it

mergedTj Holowaychukbefore adoption547d18c

lines 1–45why, one step back
1
2var express = require('../')3 , request = require('./support/http');45describe('req', function(){6 describe('.accepts(type)', function(){7 it('should return true when Accept is not present', function(done){8 var app = express();910 app.use(function(req, res, next){11 res.end(req.accepts('json') ? 'yes' : 'no');12 });1314 request(app)15 .get('/')16 .expect('yes', done);17 })18 19 it('should return true when present', function(done){20 var app = express();2122 app.use(function(req, res, next){23 res.end(req.accepts('json') ? 'yes' : 'no');24 });2526 request(app)27 .get('/')28 .set('Accept', 'application/json')29 .expect('yes', done);30 })31 32 it('should return false otherwise', function(done){33 var app = express();3435 app.use(function(req, res, next){36 res.end(req.accepts('json') ? 'yes' : 'no');37 });3839 request(app)40 .get('/')41 .set('Accept', 'text/html')42 .expect('no', done);43 })44 })45})