Aktueller Stand
This commit is contained in:
39
backend/node_modules/fastify/test/internals/plugin.test.js
generated
vendored
39
backend/node_modules/fastify/test/internals/plugin.test.js
generated
vendored
@@ -1,19 +1,18 @@
|
||||
'use strict'
|
||||
|
||||
const t = require('tap')
|
||||
const test = t.test
|
||||
const { test } = require('node:test')
|
||||
|
||||
const pluginUtilsPublic = require('../../lib/pluginUtils.js')
|
||||
const pluginUtilsPublic = require('../../lib/plugin-utils.js')
|
||||
const symbols = require('../../lib/symbols.js')
|
||||
const pluginUtils = require('../../lib/pluginUtils')[symbols.kTestInternals]
|
||||
const pluginUtils = require('../../lib/plugin-utils')[symbols.kTestInternals]
|
||||
|
||||
test("shouldSkipOverride should check the 'skip-override' symbol", t => {
|
||||
t.plan(2)
|
||||
|
||||
yes[Symbol.for('skip-override')] = true
|
||||
|
||||
t.ok(pluginUtils.shouldSkipOverride(yes))
|
||||
t.notOk(pluginUtils.shouldSkipOverride(no))
|
||||
t.assert.ok(pluginUtils.shouldSkipOverride(yes))
|
||||
t.assert.ok(!pluginUtils.shouldSkipOverride(no))
|
||||
|
||||
function yes () {}
|
||||
function no () {}
|
||||
@@ -26,7 +25,7 @@ test('getPluginName should return plugin name if the file is cached', t => {
|
||||
require.cache[expectedPluginName] = { exports: fn }
|
||||
const pluginName = pluginUtilsPublic.getPluginName(fn)
|
||||
|
||||
t.equal(pluginName, expectedPluginName)
|
||||
t.assert.strictEqual(pluginName, expectedPluginName)
|
||||
})
|
||||
|
||||
test('getPluginName should not throw when require.cache is undefined', t => {
|
||||
@@ -36,12 +35,12 @@ test('getPluginName should not throw when require.cache is undefined', t => {
|
||||
}
|
||||
const cache = require.cache
|
||||
require.cache = undefined
|
||||
t.teardown(() => {
|
||||
t.after(() => {
|
||||
require.cache = cache
|
||||
})
|
||||
const pluginName = pluginUtilsPublic.getPluginName(example)
|
||||
|
||||
t.equal(pluginName, 'example')
|
||||
t.assert.strictEqual(pluginName, 'example')
|
||||
})
|
||||
|
||||
test("getMeta should return the object stored with the 'plugin-meta' symbol", t => {
|
||||
@@ -50,7 +49,7 @@ test("getMeta should return the object stored with the 'plugin-meta' symbol", t
|
||||
const meta = { hello: 'world' }
|
||||
fn[Symbol.for('plugin-meta')] = meta
|
||||
|
||||
t.same(meta, pluginUtils.getMeta(fn))
|
||||
t.assert.deepStrictEqual(meta, pluginUtils.getMeta(fn))
|
||||
|
||||
function fn () {}
|
||||
})
|
||||
@@ -73,9 +72,9 @@ test('checkDecorators should check if the given decorator is present in the inst
|
||||
|
||||
try {
|
||||
pluginUtils.checkDecorators.call(context, fn)
|
||||
t.pass('Everything ok')
|
||||
t.assert.ok('Everything ok')
|
||||
} catch (err) {
|
||||
t.fail(err)
|
||||
t.assert.fail(err)
|
||||
}
|
||||
|
||||
function fn () {}
|
||||
@@ -99,9 +98,9 @@ test('checkDecorators should check if the given decorator is present in the inst
|
||||
|
||||
try {
|
||||
pluginUtils.checkDecorators.call(context, fn)
|
||||
t.fail('should throw')
|
||||
t.assert.fail('should throw')
|
||||
} catch (err) {
|
||||
t.equal(err.message, "The decorator 'plugin' is not present in Request")
|
||||
t.assert.strictEqual(err.message, "The decorator 'plugin' is not present in Request")
|
||||
}
|
||||
|
||||
function fn () {}
|
||||
@@ -121,9 +120,9 @@ test('checkDecorators should accept optional decorators', t => {
|
||||
|
||||
try {
|
||||
pluginUtils.checkDecorators.call(context, fn)
|
||||
t.pass('Everything ok')
|
||||
t.assert.ok('Everything ok')
|
||||
} catch (err) {
|
||||
t.fail(err)
|
||||
t.assert.fail(err)
|
||||
}
|
||||
|
||||
function fn () {}
|
||||
@@ -141,9 +140,9 @@ test('checkDependencies should check if the given dependency is present in the i
|
||||
|
||||
try {
|
||||
pluginUtils.checkDependencies.call(context, fn)
|
||||
t.pass('Everything ok')
|
||||
t.assert.ok('Everything ok')
|
||||
} catch (err) {
|
||||
t.fail(err)
|
||||
t.assert.fail(err)
|
||||
}
|
||||
|
||||
function fn () {}
|
||||
@@ -162,9 +161,9 @@ test('checkDependencies should check if the given dependency is present in the i
|
||||
|
||||
try {
|
||||
pluginUtils.checkDependencies.call(context, fn)
|
||||
t.fail('should throw')
|
||||
t.assert.fail('should throw')
|
||||
} catch (err) {
|
||||
t.equal(err.message, "The dependency 'plugin' of plugin 'test-plugin' is not registered")
|
||||
t.assert.strictEqual(err.message, "The dependency 'plugin' of plugin 'test-plugin' is not registered")
|
||||
}
|
||||
|
||||
function fn () {}
|
||||
|
||||
Reference in New Issue
Block a user