Home / File/ inject.test.js — fastify Source File

inject.test.js — fastify Source File

Architecture documentation for inject.test.js, a javascript file in the fastify codebase.

Entity Profile

Relationship Graph

Source Code

'use strict'

const { test } = require('node:test')
const Stream = require('node:stream')
const util = require('node:util')
const Fastify = require('..')
const { Readable } = require('node:stream')

test('inject should exist', t => {
  t.plan(2)
  const fastify = Fastify()
  t.assert.ok(fastify.inject)
  t.assert.strictEqual(typeof fastify.inject, 'function')
})

test('should wait for the ready event', (t, done) => {
  t.plan(4)
  const fastify = Fastify()
  const payload = { hello: 'world' }

  fastify.register((instance, opts, done) => {
    instance.get('/', (req, reply) => {
      reply.send(payload)
    })
    setTimeout(done, 500)
  })

  fastify.inject({
    method: 'GET',
    url: '/'
  }, (err, res) => {
    t.assert.ifError(err)
    t.assert.deepStrictEqual(payload, JSON.parse(res.payload))
    t.assert.strictEqual(res.statusCode, 200)
    t.assert.strictEqual(res.headers['content-length'], '17')
    done()
  })
})

test('inject get request', (t, done) => {
  t.plan(4)
  const fastify = Fastify()
  const payload = { hello: 'world' }

  fastify.get('/', (req, reply) => {
    reply.send(payload)
  })

  fastify.inject({
    method: 'GET',
    url: '/'
  }, (err, res) => {
    t.assert.ifError(err)
    t.assert.deepStrictEqual(payload, JSON.parse(res.payload))
    t.assert.strictEqual(res.statusCode, 200)
    t.assert.strictEqual(res.headers['content-length'], '17')
    done()
  })
})

// ... (443 more lines)

Domain

Subdomains

Functions

Frequently Asked Questions

What does inject.test.js do?
inject.test.js is a source file in the fastify codebase, written in javascript. It belongs to the CoreKernel domain, InstanceFactory subdomain.
What functions are defined in inject.test.js?
inject.test.js defines 1 function(s): getStream.
Where is inject.test.js in the architecture?
inject.test.js is located at test/inject.test.js (domain: CoreKernel, subdomain: InstanceFactory, directory: test).

Analyze Your Own Codebase

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

Try Supermodel Free