docs: update homepage link http to https (#5920)
[express.git] / test / req.acceptsCharsets.js
blob360a9878a788ea3edac61eae1774cca0a34f0890
1 'use strict'
3 var express = require('../')
4 , request = require('supertest');
6 describe('req', function(){
7 describe('.acceptsCharsets(type)', function(){
8 describe('when Accept-Charset is not present', function(){
9 it('should return true', function(done){
10 var app = express();
12 app.use(function(req, res, next){
13 res.end(req.acceptsCharsets('utf-8') ? 'yes' : 'no');
14 });
16 request(app)
17 .get('/')
18 .expect('yes', done);
22 describe('when Accept-Charset is present', function () {
23 it('should return true', function (done) {
24 var app = express();
26 app.use(function(req, res, next){
27 res.end(req.acceptsCharsets('utf-8') ? 'yes' : 'no');
28 });
30 request(app)
31 .get('/')
32 .set('Accept-Charset', 'foo, bar, utf-8')
33 .expect('yes', done);
36 it('should return false otherwise', function(done){
37 var app = express();
39 app.use(function(req, res, next){
40 res.end(req.acceptsCharsets('utf-8') ? 'yes' : 'no');
41 });
43 request(app)
44 .get('/')
45 .set('Accept-Charset', 'foo, bar')
46 .expect('no', done);