Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions test/bundlers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ test('webpack removes require.main.filename', t => {
t.assert.fail('logged: ' + msg)
}

fp((fastify, opts, next) => {
fp((_fastify, _opts, next) => {
next()
}, {
fastify: '^5.0.0'
})
})

test('support faux modules', (t) => {
const plugin = fp((fastify, opts, next) => {
const plugin = fp((_fastify, _opts, next) => {
next()
})

Expand All @@ -34,7 +34,7 @@ test('support faux modules', (t) => {

test('support faux modules does not override existing default field in babel module', (t) => {
const module = {
default: (fastify, opts, next) => next()
default: (_fastify, _opts, next) => next()
}

module.default.default = 'Existing default field'
Expand All @@ -45,7 +45,7 @@ test('support faux modules does not override existing default field in babel mod
})

test('support ts named imports', (t) => {
const plugin = fp((fastify, opts, next) => {
const plugin = fp((_fastify, _opts, next) => {
next()
}, {
name: 'hello'
Expand All @@ -55,7 +55,7 @@ test('support ts named imports', (t) => {
})

test('from kebab-case to camelCase', (t) => {
const plugin = fp((fastify, opts, next) => {
const plugin = fp((_fastify, _opts, next) => {
next()
}, {
name: 'hello-world'
Expand All @@ -65,7 +65,7 @@ test('from kebab-case to camelCase', (t) => {
})

test('from @-prefixed named imports', (t) => {
const plugin = fp((fastify, opts, next) => {
const plugin = fp((_fastify, _opts, next) => {
next()
}, {
name: '@hello/world'
Expand All @@ -75,7 +75,7 @@ test('from @-prefixed named imports', (t) => {
})

test('from @-prefixed named kebab-case to camelCase', (t) => {
const plugin = fp((fastify, opts, next) => {
const plugin = fp((_fastify, _opts, next) => {
next()
}, {
name: '@hello/my-world'
Expand All @@ -85,7 +85,7 @@ test('from @-prefixed named kebab-case to camelCase', (t) => {
})

test('from kebab-case to camelCase multiple words', (t) => {
const plugin = fp((fastify, opts, next) => {
const plugin = fp((_fastify, _opts, next) => {
next()
}, {
name: 'hello-long-world'
Expand All @@ -95,7 +95,7 @@ test('from kebab-case to camelCase multiple words', (t) => {
})

test('from kebab-case to camelCase multiple words does not override', (t) => {
const fn = (fastify, opts, next) => {
const fn = (_fastify, _opts, next) => {
next()
}

Expand Down
6 changes: 3 additions & 3 deletions test/checkVersion.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test('checkVersion having require.main.filename', (t) => {
t.assert.fail('logged: ' + msg)
}

fp((fastify, opts, next) => {
fp((_fastify, _opts, next) => {
next()
}, {
fastify: '^5.0.0'
Expand All @@ -35,7 +35,7 @@ test('checkVersion having no require.main.filename but process.argv[1]', (t) =>
t.assert.fail('logged: ' + msg)
}

fp((fastify, opts, next) => {
fp((_fastify, _opts, next) => {
next()
}, {
fastify: '^5.0.0'
Expand All @@ -59,7 +59,7 @@ test('checkVersion having no require.main.filename and no process.argv[1]', (t)
t.assert.fail('logged: ' + msg)
}

fp((fastify, opts, next) => {
fp((_fastify, _opts, next) => {
next()
}, {
fastify: '^5.0.0'
Expand Down
2 changes: 1 addition & 1 deletion test/composite.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const fp = require('../plugin')

test('anonymous function should be named composite.test0', (t) => {
t.plan(2)
const fn = fp((fastify, opts, next) => {
const fn = fp((_fastify, _opts, next) => {
next()
})

Expand Down
2 changes: 1 addition & 1 deletion test/esm/esm.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { test } from 'node:test'
import fp from '../../plugin.js'

test('esm base support', (t) => {
fp((fastify, opts, next) => {
fp((_fastify, _opts, next) => {
next()
}, {
fastify: '^5.0.0'
Expand Down
2 changes: 1 addition & 1 deletion test/mu1tip1e.composite.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const fp = require('../plugin')
test('anonymous function should be named mu1tip1e.composite.test', (t) => {
t.plan(2)

const fn = fp((fastify, opts, next) => {
const fn = fp((_fastify, _opts, next) => {
next()
})

Expand Down
58 changes: 29 additions & 29 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test('fastify-plugin is a function', (t) => {
test('should return the function with the skip-override Symbol', (t) => {
t.plan(1)

function plugin (fastify, opts, next) {
function plugin (_fastify, _opts, next) {
next()
}

Expand Down Expand Up @@ -52,29 +52,29 @@ test('should throw if the plugin is not a function', (t) => {
test('should check the fastify version', (t) => {
t.plan(1)

function plugin (fastify, opts, next) {
function plugin (_fastify, _opts, next) {
next()
}

try {
fp(plugin, { fastify: '>=0.10.0' })
t.assert.ok(true)
} catch (e) {
} catch {
t.assert.fail()
}
})

test('should check the fastify version', (t) => {
t.plan(1)

function plugin (fastify, opts, next) {
function plugin (_fastify, _opts, next) {
next()
}

try {
fp(plugin, '>=0.10.0')
t.assert.ok(true)
} catch (e) {
} catch {
t.assert.fail()
}
})
Expand Down Expand Up @@ -113,7 +113,7 @@ test('Should accept an option object', (t) => {

const opts = { hello: 'world' }

function plugin (fastify, opts, next) {
function plugin (_fastify, _opts, next) {
next()
}

Expand All @@ -128,7 +128,7 @@ test('Should accept an option object and checks the version', (t) => {

const opts = { hello: 'world', fastify: '>=0.10.0' }

function plugin (fastify, opts, next) {
function plugin (_fastify, _opts, next) {
next()
}

Expand All @@ -140,14 +140,14 @@ test('Should accept an option object and checks the version', (t) => {
test('should set anonymous function name to file it was called from with a counter', (t) => {
const fp = proxyquire('../plugin.js', { stubs: {} })

const fn = fp((fastify, opts, next) => {
const fn = fp((_fastify, _opts, next) => {
next()
})

t.assert.strictEqual(fn[Symbol.for('plugin-meta')].name, 'test-auto-0')
t.assert.strictEqual(fn[Symbol.for('fastify.display-name')], 'test-auto-0')

const fn2 = fp((fastify, opts, next) => {
const fn2 = fp((_fastify, _opts, next) => {
next()
})

Expand All @@ -160,14 +160,14 @@ test('should set function name if Error.stackTraceLimit is set to 0', (t) => {

const fp = proxyquire('../plugin.js', { stubs: {} })

const fn = fp((fastify, opts, next) => {
const fn = fp((_fastify, _opts, next) => {
next()
})

t.assert.strictEqual(fn[Symbol.for('plugin-meta')].name, 'test-auto-0')
t.assert.strictEqual(fn[Symbol.for('fastify.display-name')], 'test-auto-0')

const fn2 = fp((fastify, opts, next) => {
const fn2 = fp((_fastify, _opts, next) => {
next()
})

Expand All @@ -182,7 +182,7 @@ test('should set display-name to meta name', (t) => {

const functionName = 'superDuperSpecialFunction'

const fn = fp((fastify, opts, next) => next(), {
const fn = fp((_fastify, _opts, next) => next(), {
name: functionName
})

Expand All @@ -195,7 +195,7 @@ test('should preserve fastify version in meta', (t) => {

const opts = { hello: 'world', fastify: '>=0.10.0' }

const fn = fp((fastify, opts, next) => next(), opts)
const fn = fp((_fastify, _opts, next) => next(), opts)

t.assert.strictEqual(fn[Symbol.for('plugin-meta')].fastify, '>=0.10.0')
})
Expand All @@ -204,12 +204,12 @@ test('should check fastify dependency graph - plugin', async (t) => {
t.plan(1)
const fastify = Fastify()

fastify.register(fp((fastify, opts, next) => next(), {
fastify.register(fp((_fastify, _opts, next) => next(), {
fastify: '5.x',
name: 'plugin1-name'
}))

fastify.register(fp((fastify, opts, next) => next(), {
fastify.register(fp((_fastify, _opts, next) => next(), {
fastify: '5.x',
name: 'test',
dependencies: ['plugin1-name', 'plugin2-name']
Expand All @@ -222,12 +222,12 @@ test('should check fastify dependency graph - decorate', async (t) => {
t.plan(1)
const fastify = Fastify()

fastify.decorate('plugin1', fp((fastify, opts, next) => next(), {
fastify.decorate('plugin1', fp((_fastify, _opts, next) => next(), {
fastify: '5.x',
name: 'plugin1-name'
}))

fastify.register(fp((fastify, opts, next) => next(), {
fastify.register(fp((_fastify, _opts, next) => next(), {
fastify: '5.x',
name: 'test',
decorators: { fastify: ['plugin1', 'plugin2'] }
Expand All @@ -240,12 +240,12 @@ test('should check fastify dependency graph - decorateReply', async (t) => {
t.plan(1)
const fastify = Fastify()

fastify.decorateReply('plugin1', fp((fastify, opts, next) => next(), {
fastify.decorateReply('plugin1', fp((_fastify, _opts, next) => next(), {
fastify: '5.x',
name: 'plugin1-name'
}))

fastify.register(fp((fastify, opts, next) => next(), {
fastify.register(fp((_fastify, _opts, next) => next(), {
fastify: '5.x',
name: 'test',
decorators: { reply: ['plugin1', 'plugin2'] }
Expand All @@ -259,22 +259,22 @@ test('should accept an option to encapsulate', async (t) => {

const fastify = Fastify()

fastify.register(fp((fastify, opts, next) => {
fastify.register(fp((fastify, _opts, next) => {
fastify.decorate('accessible', true)
next()
}, {
name: 'accessible-plugin'
}))

fastify.register(fp((fastify, opts, next) => {
fastify.register(fp((fastify, _opts, next) => {
fastify.decorate('alsoAccessible', true)
next()
}, {
name: 'accessible-plugin2',
encapsulate: false
}))

fastify.register(fp((fastify, opts, next) => {
fastify.register(fp((fastify, _opts, next) => {
fastify.decorate('encapsulated', true)
next()
}, {
Expand All @@ -293,7 +293,7 @@ test('should check dependencies when encapsulated', async (t) => {
t.plan(1)
const fastify = Fastify()

fastify.register(fp((fastify, opts, next) => next(), {
fastify.register(fp((_fastify, _opts, next) => next(), {
name: 'test',
dependencies: ['missing-dependency-name'],
encapsulate: true
Expand All @@ -309,7 +309,7 @@ test(
t.plan(1)
const fastify = Fastify()

fastify.register(fp((fastify, opts, next) => next(), {
fastify.register(fp((_fastify, _opts, next) => next(), {
name: 'test',
fastify: '<=2.10.0',
encapsulate: true
Expand All @@ -325,7 +325,7 @@ test('should check decorators when encapsulated', async (t) => {

fastify.decorate('plugin1', 'foo')

fastify.register(fp((fastify, opts, next) => next(), {
fastify.register(fp((_fastify, _opts, next) => next(), {
fastify: '5.x',
name: 'test',
encapsulate: true,
Expand All @@ -339,7 +339,7 @@ test('plugin name when encapsulated', async (t) => {
t.plan(6)
const fastify = Fastify()

fastify.register(function plugin (instance, opts, next) {
fastify.register(function plugin (_instance, _opts, next) {
next()
})

Expand All @@ -349,14 +349,14 @@ test('plugin name when encapsulated', async (t) => {
encapsulate: true
}))

fastify.register(function plugin (fastify, opts, next) {
fastify.register(function plugin (fastify, _opts, next) {
fastify.register(fp(getFn('deep'), {
fastify: '5.x',
name: 'deep',
encapsulate: true
}))

fastify.register(fp(function genericPlugin (fastify, opts, next) {
fastify.register(fp(function genericPlugin (fastify, _opts, next) {
t.assert.strictEqual(fastify.pluginName, 'deep-deep', 'should be deep-deep')

fastify.register(fp(getFn('deep-deep-deep'), {
Expand Down Expand Up @@ -388,7 +388,7 @@ test('plugin name when encapsulated', async (t) => {
await fastify.ready()

function getFn (expectedName) {
return function genericPlugin (fastify, opts, next) {
return function genericPlugin (fastify, _opts, next) {
t.assert.strictEqual(fastify.pluginName, expectedName, `should be ${expectedName}`)
next()
}
Expand Down
Loading
Loading