diff --git a/index.js b/index.js index c675cfd..8fa74f4 100644 --- a/index.js +++ b/index.js @@ -70,11 +70,12 @@ var mediaType = { * @api public */ -exports = module.exports = function directory(root, options){ +exports = module.exports = function serveIndex(root, options){ options = options || {}; // root required - if (!root) throw new Error('directory() root path required'); + if (!root) throw new TypeError('serveIndex() root path required'); + var hidden = options.hidden , icons = options.icons , view = options.view || 'tiles' @@ -83,7 +84,7 @@ exports = module.exports = function directory(root, options){ , template = options.template || defaultTemplate , stylesheet = options.stylesheet || defaultStylesheet; - return function directory(req, res, next) { + return function serveIndex(req, res, next) { if ('GET' != req.method && 'HEAD' != req.method) return next(); var url = parse(req.url) diff --git a/test/test.js b/test/test.js index d6bcf59..271921d 100644 --- a/test/test.js +++ b/test/test.js @@ -4,7 +4,11 @@ var request = require('supertest'); var should = require('should'); var serveIndex = require('..'); -describe('directory()', function(){ +describe('serveIndex(root)', function () { + it('should require root', function () { + serveIndex.should.throw(/root path required/) + }) + describe('when given Accept: header', function () { describe('when Accept: application/json is given', function () { it('should respond with json', function (done) {