Files
express/test/res.charset.js
2014-05-18 00:57:54 -04:00

35 lines
805 B
JavaScript

var express = require('../')
, request = require('supertest');
describe('res', function(){
describe('.charset', function(){
it('should add the charset param to Content-Type', function(done){
var app = express();
app.use(function(req, res){
res.charset = 'utf-8';
res.set('Content-Type', 'text/x-foo');
res.end(res.get('Content-Type'));
});
request(app)
.get('/')
.expect("text/x-foo; charset=utf-8", done);
})
it('should take precedence over res.send() defaults', function(done){
var app = express();
app.use(function(req, res){
res.charset = 'whoop';
res.send('hey');
});
request(app)
.get('/')
.expect('Content-Type', 'text/html; charset=whoop', done);
})
})
})