koa-lite/test/request/charset.js

29 lines
734 B
JavaScript
Raw Permalink Normal View History

2014-02-14 17:38:59 +00:00
var request = require('../context').request;
var assert = require('assert');
describe('req.charset', function(){
describe('with no content-type present', function(){
it('should return null', function(){
var req = request();
assert(null == req.charset);
})
})
describe('with charset present', function(){
it('should return null', function(){
var req = request();
req.header['content-type'] = 'text/plain';
assert(null == req.charset);
})
})
describe('with a charset', function(){
it('should return the charset', function(){
var req = request();
req.header['content-type'] = 'text/plain; charset=utf-8';
req.charset.should.equal('utf-8');
})
})
2014-07-05 17:36:52 +00:00
})