Home / File/ hook-runner.test.js — fastify Source File

hook-runner.test.js — fastify Source File

Architecture documentation for hook-runner.test.js, a javascript file in the fastify codebase.

Entity Profile

Source Code

'use strict'

const { test } = require('node:test')
const { hookRunnerGenerator, onSendHookRunner } = require('../../lib/hooks')

test('hookRunner - Basic', t => {
  t.plan(9)

  const hookRunner = hookRunnerGenerator(iterator)

  hookRunner([fn1, fn2, fn3], 'a', 'b', done)

  function iterator (fn, a, b, done) {
    return fn(a, b, done)
  }

  function fn1 (a, b, done) {
    t.assert.strictEqual(a, 'a')
    t.assert.strictEqual(b, 'b')
    done()
  }

  function fn2 (a, b, done) {
    t.assert.strictEqual(a, 'a')
    t.assert.strictEqual(b, 'b')
    done()
  }

  function fn3 (a, b, done) {
    t.assert.strictEqual(a, 'a')
    t.assert.strictEqual(b, 'b')
    done()
  }

  function done (err, a, b) {
    t.assert.ifError(err)
    t.assert.strictEqual(a, 'a')
    t.assert.strictEqual(b, 'b')
  }
})

test('hookRunner - In case of error should skip to done', t => {
  t.plan(7)

  const hookRunner = hookRunnerGenerator(iterator)

  hookRunner([fn1, fn2, fn3], 'a', 'b', done)

  function iterator (fn, a, b, done) {
    return fn(a, b, done)
  }

  function fn1 (a, b, done) {
    t.assert.strictEqual(a, 'a')
    t.assert.strictEqual(b, 'b')
    done()
  }

  function fn2 (a, b, done) {
    t.assert.strictEqual(a, 'a')
// ... (390 more lines)

Frequently Asked Questions

What does hook-runner.test.js do?
hook-runner.test.js is a source file in the fastify codebase, written in javascript.
Where is hook-runner.test.js in the architecture?
hook-runner.test.js is located at test/internals/hook-runner.test.js (directory: test/internals).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free