koa-lite/test/request/charset.js

31 lines
753 B
JavaScript
Raw Normal View History

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