2013-11-13 17:01:15 +00:00
|
|
|
|
|
|
|
var context = require('../context');
|
|
|
|
var assert = require('assert');
|
|
|
|
|
|
|
|
describe('ctx.type=', function(){
|
|
|
|
describe('with a mime', function(){
|
|
|
|
it('should set the Content-Type', function(){
|
|
|
|
var ctx = context();
|
|
|
|
ctx.type = 'text/plain';
|
2014-02-14 17:16:39 +00:00
|
|
|
ctx.type.should.equal('text/plain');
|
2013-11-13 17:01:15 +00:00
|
|
|
ctx.response.header['content-type'].should.equal('text/plain');
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('with an extension', function(){
|
|
|
|
it('should lookup the mime', function(){
|
|
|
|
var ctx = context();
|
|
|
|
ctx.type = 'json';
|
2014-02-14 17:16:39 +00:00
|
|
|
ctx.type.should.equal('application/json');
|
2013-11-13 17:01:15 +00:00
|
|
|
ctx.response.header['content-type'].should.equal('application/json');
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('ctx.type', function(){
|
|
|
|
describe('with no Content-Type', function(){
|
|
|
|
it('should return null', function(){
|
|
|
|
var ctx = context();
|
2014-02-14 17:16:39 +00:00
|
|
|
// TODO: this is lame
|
2013-11-13 17:01:15 +00:00
|
|
|
assert(null == ctx.type);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('with a Content-Type', function(){
|
|
|
|
it('should return the mime', function(){
|
|
|
|
var ctx = context();
|
2014-02-14 17:16:39 +00:00
|
|
|
ctx.type = 'json';
|
|
|
|
ctx.type.should.equal('application/json');
|
2013-11-13 17:01:15 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|