fastify-plugin
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -14,2 +14,8 @@ 'use strict' | ||
if (options === undefined) return fn | ||
if (typeof options === 'string') { | ||
checkVersion(options) | ||
return fn | ||
} | ||
if (typeof options !== 'object' || Array.isArray(options) || options === null) { | ||
@@ -16,0 +22,0 @@ throw new TypeError('The options object should be an object') |
{ | ||
"name": "fastify-plugin", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Plugin helper for Fastify", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -39,2 +39,4 @@ # fastify-plugin | ||
If you need to check the Fastify version only, you can pass just the version string. | ||
You can check [here](https://github.com/npm/node-semver#ranges) how to define a `semver` range. | ||
@@ -41,0 +43,0 @@ |
22
test.js
@@ -50,14 +50,22 @@ 'use strict' | ||
test('the options object should be an object', t => { | ||
t.plan(3) | ||
test('should check the fastify version', t => { | ||
t.plan(1) | ||
function plugin (fastify, opts, next) { | ||
next() | ||
} | ||
try { | ||
fp(() => {}, null) | ||
fp(plugin, '>=0.10.0') | ||
t.pass() | ||
} catch (e) { | ||
t.fail() | ||
} catch (e) { | ||
t.is(e.message, 'The options object should be an object') | ||
} | ||
}) | ||
test('the options object should be an object', t => { | ||
t.plan(2) | ||
try { | ||
fp(() => {}, []) | ||
fp(() => {}, null) | ||
t.fail() | ||
@@ -69,3 +77,3 @@ } catch (e) { | ||
try { | ||
fp(() => {}, 'abc') | ||
fp(() => {}, []) | ||
t.fail() | ||
@@ -72,0 +80,0 @@ } catch (e) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8728
174
70