Projektstart
This commit is contained in:
61
backend/node_modules/fastify/test/diagnostics-channel.test.js
generated
vendored
Normal file
61
backend/node_modules/fastify/test/diagnostics-channel.test.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
'use strict'
|
||||
|
||||
const t = require('tap')
|
||||
const test = t.test
|
||||
const proxyquire = require('proxyquire')
|
||||
|
||||
test('diagnostics_channel when present and subscribers', t => {
|
||||
t.plan(3)
|
||||
|
||||
let fastifyInHook
|
||||
|
||||
const dc = {
|
||||
channel (name) {
|
||||
t.equal(name, 'fastify.initialization')
|
||||
return {
|
||||
hasSubscribers: true,
|
||||
publish (event) {
|
||||
t.ok(event.fastify)
|
||||
fastifyInHook = event.fastify
|
||||
}
|
||||
}
|
||||
},
|
||||
'@noCallThru': true
|
||||
}
|
||||
|
||||
const fastify = proxyquire('../fastify', {
|
||||
'node:diagnostics_channel': dc
|
||||
})()
|
||||
t.equal(fastifyInHook, fastify)
|
||||
})
|
||||
|
||||
test('diagnostics_channel when present and no subscribers', t => {
|
||||
t.plan(1)
|
||||
|
||||
const dc = {
|
||||
channel (name) {
|
||||
t.equal(name, 'fastify.initialization')
|
||||
return {
|
||||
hasSubscribers: false,
|
||||
publish () {
|
||||
t.fail('publish should not be called')
|
||||
}
|
||||
}
|
||||
},
|
||||
'@noCallThru': true
|
||||
}
|
||||
|
||||
proxyquire('../fastify', {
|
||||
'node:diagnostics_channel': dc
|
||||
})()
|
||||
})
|
||||
|
||||
test('diagnostics_channel when not present', t => {
|
||||
t.plan(1)
|
||||
|
||||
t.doesNotThrow(() => {
|
||||
proxyquire('../fastify', {
|
||||
'node:diagnostics_channel': null
|
||||
})()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user