CoolFace
Apppublic

strong-tie/inbound-calls

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
init.test.js51 linesDownload Raw Back to diagnostics-channel
1'use strict'2 3const { test } = require('node:test')4const proxyquire = require('proxyquire')5 6test('diagnostics_channel when present and subscribers', t => {7  t.plan(3)8 9  let fastifyInHook10 11  const diagnostics = {12    channel (name) {13      t.assert.strictEqual(name, 'fastify.initialization')14      return {15        hasSubscribers: true,16        publish (event) {17          t.assert.ok(event.fastify)18          fastifyInHook = event.fastify19        }20      }21    },22    '@noCallThru': true23  }24 25  const fastify = proxyquire('../../fastify', {26    'node:diagnostics_channel': diagnostics27  })()28  t.assert.strictEqual(fastifyInHook, fastify)29})30 31test('diagnostics_channel when present and no subscribers', t => {32  t.plan(1)33 34  const diagnostics = {35    channel (name) {36      t.assert.strictEqual(name, 'fastify.initialization')37      return {38        hasSubscribers: false,39        publish () {40          t.assert.fail('publish should not be called')41        }42      }43    },44    '@noCallThru': true45  }46 47  proxyquire('../../fastify', {48    'node:diagnostics_channel': diagnostics49  })()50})51