diff --git a/medley.js b/medley.js index b33823b..7248c3b 100644 --- a/medley.js +++ b/medley.js @@ -28,7 +28,7 @@ function medley(options) { options = options || {} if (options.queryParser !== undefined && typeof options.queryParser !== 'function') { - throw new TypeError(`'queryParser' option must be an function. Got a '${typeof options.queryParser}'`) + throw new TypeError(`'queryParser' option must be a function. Got value of type '${typeof options.queryParser}'`) } const router = findMyWay({ diff --git a/test/queryParser-option.test.js b/test/queryParser-option.test.js index fe82072..c34aac7 100644 --- a/test/queryParser-option.test.js +++ b/test/queryParser-option.test.js @@ -5,16 +5,21 @@ const medley = require('..') const request = require('./utils/request') t.test('queryParser', (t) => { - t.plan(6) + t.plan(7) t.throws( () => medley({queryParser: true}), - new TypeError("'queryParser' option must be an function. Got a 'boolean'") + new TypeError("'queryParser' option must be a function. Got value of type 'boolean'") ) t.throws( () => medley({queryParser: 'simple'}), - new TypeError("'queryParser' option must be an function. Got a 'string'") + new TypeError("'queryParser' option must be a function. Got value of type 'string'") + ) + + t.throws( + () => medley({queryParser: []}), + new TypeError("'queryParser' option must be a function. Got value of type 'object'") ) const app = medley({