output-validation.test.js — fastify Source File
Architecture documentation for output-validation.test.js, a javascript file in the fastify codebase.
Entity Profile
Source Code
'use strict'
const { test } = require('node:test')
const fastify = require('..')()
const opts = {
schema: {
response: {
200: {
type: 'object',
properties: {
hello: {
type: 'string'
}
}
},
'2xx': {
type: 'object',
properties: {
hello: {
type: 'number'
}
}
}
}
}
}
test('shorthand - output string', t => {
t.plan(1)
try {
fastify.get('/string', opts, function (req, reply) {
reply.code(200).send({ hello: 'world' })
})
t.assert.ok(true)
} catch (e) {
t.assert.fail()
}
})
test('shorthand - output number', t => {
t.plan(1)
try {
fastify.get('/number', opts, function (req, reply) {
reply.code(201).send({ hello: 55 })
})
t.assert.ok(true)
} catch (e) {
t.assert.fail()
}
})
test('wrong object for schema - output', t => {
t.plan(1)
try {
fastify.get('/wrong-object-for-schema', opts, function (req, reply) {
// will send { }
reply.code(201).send({ hello: 'world' })
})
t.assert.ok(true)
// ... (81 more lines)
Source
Frequently Asked Questions
What does output-validation.test.js do?
output-validation.test.js is a source file in the fastify codebase, written in javascript.
Where is output-validation.test.js in the architecture?
output-validation.test.js is located at test/output-validation.test.js (directory: test).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free