Home / File/ pretty-print.test.js — fastify Source File

pretty-print.test.js — fastify Source File

Architecture documentation for pretty-print.test.js, a javascript file in the fastify codebase.

Entity Profile

Source Code

'use strict'

const { test } = require('node:test')
const Fastify = require('..')

test('pretty print - static routes', (t, done) => {
  t.plan(2)

  const fastify = Fastify({ exposeHeadRoutes: false })
  fastify.get('/test', () => {})
  fastify.get('/test/hello', () => {})
  fastify.get('/hello/world', () => {})

  fastify.ready(() => {
    const tree = fastify.printRoutes()

    const expected = `\
└── /
    ├── test (GET)
    │   └── /hello (GET)
    └── hello/world (GET)
`

    t.assert.strictEqual(typeof tree, 'string')
    t.assert.strictEqual(tree, expected)
    done()
  })
})

test('pretty print - internal tree - static routes', (t, done) => {
  t.plan(4)

  const fastify = Fastify({ exposeHeadRoutes: false })
  fastify.get('/test', () => {})
  fastify.get('/test/hello', () => {})
  fastify.get('/hello/world', () => {})

  fastify.put('/test', () => {})
  fastify.put('/test/foo', () => {})

  fastify.ready(() => {
    const getTree = fastify.printRoutes({ method: 'GET' })
    const expectedGetTree = `\
└── /
    ├── test (GET)
    │   └── /hello (GET)
    └── hello/world (GET)
`

    t.assert.strictEqual(typeof getTree, 'string')
    t.assert.strictEqual(getTree, expectedGetTree)

    const putTree = fastify.printRoutes({ method: 'PUT' })
    const expectedPutTree = `\
└── /
    └── test (PUT)
        └── /foo (PUT)
`

    t.assert.strictEqual(typeof putTree, 'string')
// ... (307 more lines)

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free