Skip to content

Commit

Permalink
Added two tests. One to check for defaultContentType if it's set and …
Browse files Browse the repository at this point in the history
…the other to verify content-type is application/octet-stream if default not set.
  • Loading branch information
jprichardson committed Sep 20, 2012
1 parent a30fc30 commit 715bcd8
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/simple.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -120,6 +120,30 @@ describe('simple test', function() {
req.end(); req.end();
}); });


it('serves the default content type specified in the options if it cant detect the mime', function(done) {
var dcPort = 42917
, dcBaseUrl = 'http://localhost:' + dcPort
, defaultType = 'text/crazy' //use something that we know doesn't exist
, handler = buffet(testFolder, {defaultContentType: defaultType})
;

var server = http.createServer(handler).listen(dcPort, function() {
var req = http.get(dcBaseUrl + '/index', function(res) {
assert.equal(res.statusCode, 200);
assert.equal(res.headers['content-type'], defaultType);
server.close(done);
});
});
});

it('serves the application/octet-stream when no defaultContentType is and it cant detect the mime', function(done) {
var req = http.get(baseUrl + '/index', function(res) {
assert.equal(res.statusCode, 200);
assert.equal(res.headers['content-type'], 'application/octet-stream');
done();
});
});

describe('watcher', function() { describe('watcher', function() {
var testData = {yay: true}, folderName = idgen(); var testData = {yay: true}, folderName = idgen();
before(function(done) { before(function(done) {
Expand Down

0 comments on commit 715bcd8

Please sign in to comment.