fastify-plugin
Advanced tools
Comparing version 2.0.3 to 2.1.0
{ | ||
"name": "fastify-plugin", | ||
"version": "2.0.3", | ||
"version": "2.1.0", | ||
"description": "Plugin helper for Fastify", | ||
@@ -5,0 +5,0 @@ "main": "plugin.js", |
@@ -8,2 +8,4 @@ 'use strict' | ||
let count = 0 | ||
function plugin (fn, options = {}) { | ||
@@ -32,3 +34,3 @@ if (typeof fn.default !== 'undefined') { // Support for 'export default' behaviour in transpiled ECMAScript module | ||
if (!options.name) { | ||
options.name = pluginName | ||
options.name = pluginName + '-auto-' + count++ | ||
} | ||
@@ -35,0 +37,0 @@ |
@@ -7,3 +7,3 @@ 'use strict' | ||
test('anonymous function should be named composite.test', t => { | ||
test('anonymous function should be named composite.test0', t => { | ||
t.plan(2) | ||
@@ -15,4 +15,4 @@ | ||
t.is(fn[Symbol.for('plugin-meta')].name, 'composite.test') | ||
t.is(fn[Symbol.for('fastify.display-name')], 'composite.test') | ||
t.is(fn[Symbol.for('plugin-meta')].name, 'composite.test-auto-0') | ||
t.is(fn[Symbol.for('fastify.display-name')], 'composite.test-auto-0') | ||
}) |
@@ -14,4 +14,4 @@ 'use strict' | ||
t.is(fn[Symbol.for('plugin-meta')].name, 'mu1tip1e.composite.test') | ||
t.is(fn[Symbol.for('fastify.display-name')], 'mu1tip1e.composite.test') | ||
t.is(fn[Symbol.for('plugin-meta')].name, 'mu1tip1e.composite.test-auto-0') | ||
t.is(fn[Symbol.for('fastify.display-name')], 'mu1tip1e.composite.test-auto-0') | ||
}) |
@@ -206,4 +206,4 @@ 'use strict' | ||
test('should set anonymous function name to file it was called from', t => { | ||
t.plan(2) | ||
test('should set anonymous function name to file it was called from with a counter', t => { | ||
const fp = proxyquire('../plugin.js', { stubs: {} }) | ||
@@ -214,4 +214,13 @@ const fn = fp((fastify, opts, next) => { | ||
t.is(fn[Symbol.for('plugin-meta')].name, 'test') | ||
t.is(fn[Symbol.for('fastify.display-name')], 'test') | ||
t.is(fn[Symbol.for('plugin-meta')].name, 'test-auto-0') | ||
t.is(fn[Symbol.for('fastify.display-name')], 'test-auto-0') | ||
const fn2 = fp((fastify, opts, next) => { | ||
next() | ||
}) | ||
t.is(fn2[Symbol.for('plugin-meta')].name, 'test-auto-1') | ||
t.is(fn2[Symbol.for('fastify.display-name')], 'test-auto-1') | ||
t.end() | ||
}) | ||
@@ -218,0 +227,0 @@ |
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
22234
469