Skip to content

Commit

Permalink
Coverage. For #1515
Browse files Browse the repository at this point in the history
  • Loading branch information
Eran Hammer committed Mar 24, 2014
1 parent fd358c5 commit db57d99
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ internals.Response.prototype._prepare = function (request, callback) {
self.source.stat = stat;

self.bytes(stat.size);
self.type(Mime.lookup(path) || 'application/octet-stream');
self.type(Mime.lookup(path));
self._header('last-modified', stat.mtime);

if (request.server._etags) {
Expand Down
23 changes: 23 additions & 0 deletions test/pack.js
Original file line number Diff line number Diff line change
Expand Up @@ -798,4 +798,27 @@ describe('Pack', function () {
done();
});
});

describe('#_provisionCache ', function () {

it('throws when creating method cache with invalid segment', function (done) {

var server = new Hapi.Server();
expect(function () {

server.pack._provisionCache({ expiresIn: 1000 }, 'method', 'steve', 'bad');
}).to.throw('Server method cache segment must start with \'##\'');
done();
});

it('throws when creating plugin cache with invalid segment', function (done) {

var server = new Hapi.Server();
expect(function () {

server.pack._provisionCache({ expiresIn: 1000 }, 'plugin', 'steve', 'bad');
}).to.throw('Plugin cache segment must start with \'!!\'');
done();
});
});
});
11 changes: 11 additions & 0 deletions test/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,17 @@ describe('Response', function () {
});
});

it('returns a file with default mime type', function (done) {

var server = new Hapi.Server();
server.route({ method: 'GET', path: '/', handler: { file: __dirname + '/../bin/hapi' } });

server.inject('/', function (res) {

expect(res.headers['content-type']).to.equal('application/octet-stream');
done();
});
});

it('does not cache etags', function (done) {

Expand Down

0 comments on commit db57d99

Please sign in to comment.