Files
express/test/req.acceptsEncoding.js

37 lines
850 B
JavaScript
Raw Permalink Normal View History

2014-05-20 23:07:53 -04:00
var express = require('../')
, request = require('supertest');
describe('req', function(){
describe('.acceptsEncoding', function(){
2014-05-20 23:07:53 -04:00
it('should be true if encoding accpeted', function(done){
var app = express();
app.use(function(req, res){
2014-05-21 02:08:04 -04:00
req.acceptsEncoding('gzip').should.be.ok;
req.acceptsEncoding('deflate').should.be.ok;
2014-05-20 23:07:53 -04:00
res.end();
});
request(app)
.get('/')
.set('Accept-Encoding', ' gzip, deflate')
.expect(200, done);
})
it('should be false if encoding not accpeted', function(done){
var app = express();
app.use(function(req, res){
2014-05-21 02:08:04 -04:00
req.acceptsEncoding('bogus').should.not.be.ok;
2014-05-20 23:07:53 -04:00
res.end();
});
request(app)
.get('/')
.set('Accept-Encoding', ' gzip, deflate')
.expect(200, done);
})
})
})