Aktueller Stand

This commit is contained in:
2026-01-22 19:05:45 +01:00
parent 85dee61a4d
commit e280e4eadb
1967 changed files with 397327 additions and 74093 deletions

View File

@@ -1,12 +1,12 @@
'use strict'
const { test } = require('tap')
const { test } = require('node:test')
const fp = require('../plugin')
test('webpack removes require.main.filename', (t) => {
test('webpack removes require.main.filename', t => {
const filename = require.main.filename
const info = console.info
t.teardown(() => {
t.after(() => {
require.main.filename = filename
console.info = info
})
@@ -14,97 +14,88 @@ test('webpack removes require.main.filename', (t) => {
require.main.filename = null
console.info = function (msg) {
t.fail('logged: ' + msg)
t.assert.fail('logged: ' + msg)
}
fp((fastify, opts, next) => {
fp((_fastify, _opts, next) => {
next()
}, {
fastify: '^4.0.0'
fastify: '^5.0.0'
})
t.end()
})
test('support faux modules', (t) => {
const plugin = fp((fastify, opts, next) => {
const plugin = fp((_fastify, _opts, next) => {
next()
})
t.equal(plugin.default, plugin)
t.end()
t.assert.strictEqual(plugin.default, plugin)
})
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'
const plugin = fp(module)
t.equal(plugin.default, 'Existing default field')
t.end()
t.assert.strictEqual(plugin.default, 'Existing default field')
})
test('support ts named imports', (t) => {
const plugin = fp((fastify, opts, next) => {
const plugin = fp((_fastify, _opts, next) => {
next()
}, {
name: 'hello'
})
t.equal(plugin.hello, plugin)
t.end()
t.assert.strictEqual(plugin.hello, plugin)
})
test('from kebab-case to camelCase', (t) => {
const plugin = fp((fastify, opts, next) => {
const plugin = fp((_fastify, _opts, next) => {
next()
}, {
name: 'hello-world'
})
t.equal(plugin.helloWorld, plugin)
t.end()
t.assert.strictEqual(plugin.helloWorld, plugin)
})
test('from @-prefixed named imports', (t) => {
const plugin = fp((fastify, opts, next) => {
const plugin = fp((_fastify, _opts, next) => {
next()
}, {
name: '@hello/world'
})
t.equal(plugin.helloWorld, plugin)
t.end()
t.assert.strictEqual(plugin.helloWorld, plugin)
})
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'
})
t.equal(plugin.helloMyWorld, plugin)
t.end()
t.assert.strictEqual(plugin.helloMyWorld, plugin)
})
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'
})
t.equal(plugin.helloLongWorld, plugin)
t.end()
t.assert.strictEqual(plugin.helloLongWorld, plugin)
})
test('from kebab-case to camelCase multiple words does not override', (t) => {
const fn = (fastify, opts, next) => {
const fn = (_fastify, _opts, next) => {
next()
}
@@ -115,6 +106,5 @@ test('from kebab-case to camelCase multiple words does not override', (t) => {
name: 'hello-long-world'
})
t.equal(plugin.helloLongWorld, foobar)
t.end()
t.assert.strictEqual(plugin.helloLongWorld, foobar)
})