koa-lite/test/response/charset.js
2014-02-14 09:33:10 -08:00

41 lines
No EOL
1.1 KiB
JavaScript

var context = require('../context');
var assert = require('assert');
describe('ctx.charset=', function(){
describe('with no charset present', function(){
it('should set it', function(){
var ctx = context();
ctx.type = 'text/plain';
ctx.charset = 'utf8';
ctx.response.get('Content-Type').should.equal('text/plain; charset=utf8');
})
})
describe('with a charset', function(){
it('should set it', function(){
var ctx = context();
ctx.type = 'text/plain; charset=hey';
ctx.charset = 'utf8';
ctx.response.get('Content-Type').should.equal('text/plain; charset=utf8');
})
})
})
describe('ctx.charset', function(){
describe('with no charset present', function(){
it('should return null', function(){
var ctx = context();
ctx.type = 'text/plain';
assert(null == ctx.charset);
})
})
describe('with a charset', function(){
it('should return the charset', function(){
var ctx = context();
ctx.type = 'text';
ctx.charset.should.equal('utf-8');
})
})
})