tests: fix req.acceptsEncodings tests
[express.git] / test / req.acceptsEncodings.js
blob9f8973cdfb8970452bdd69fbd29473ef407714b2
1 'use strict'
3 var express = require('../')
4   , request = require('supertest');
6 describe('req', function(){
7   describe('.acceptsEncodings', function () {
8     it('should return encoding if accepted', function (done) {
9       var app = express();
11       app.get('/', function (req, res) {
12         res.send({
13           gzip: req.acceptsEncodings('gzip'),
14           deflate: req.acceptsEncodings('deflate')
15         })
16       })
18       request(app)
19         .get('/')
20         .set('Accept-Encoding', ' gzip, deflate')
21         .expect(200, { gzip: 'gzip', deflate: 'deflate' }, done)
22     })
24     it('should be false if encoding not accepted', function(done){
25       var app = express();
27       app.get('/', function (req, res) {
28         res.send({
29           bogus: req.acceptsEncodings('bogus')
30         })
31       })
33       request(app)
34         .get('/')
35         .set('Accept-Encoding', ' gzip, deflate')
36         .expect(200, { bogus: false }, done)
37     })
38   })