res.type.js
This file
Path
test/res.type.js
44 lines · 1.1 KiB · JavaScript
Last changed by
Not known.
History of this fileTake it
123456789101112131415161718192021222324252627282930313233343536373839404142434445
var express = require('../') , request = require('./support/http');
describe('res', function(){ describe('.type(str)', function(){ it('should set the Content-Type based on a filename', function(done){ var app = express();
app.use(function(req, res){ res.type('foo.js').end('var name = "tj";'); });
request(app) .get('/') .expect('Content-Type', 'application/javascript', done); })
it('should default to application/octet-stream', function(done){ var app = express();
app.use(function(req, res){ res.type('rawr').end('var name = "tj";'); });
request(app) .get('/') .expect('Content-Type', 'application/octet-stream', done); })
it('should set the Content-Type with type/subtype', function(done){ var app = express();
app.use(function(req, res){ res.type('application/vnd.amazon.ebook') .end('var name = "tj";'); });
request(app) .get('/') .expect('Content-Type', 'application/vnd.amazon.ebook', done); }) })})