schema-feature.test.js — fastify Source File
Architecture documentation for schema-feature.test.js, a javascript file in the fastify codebase.
Entity Profile
Relationship Graph
Source Code
'use strict'
const { test } = require('node:test')
const Fastify = require('..')
const fp = require('fastify-plugin')
const deepClone = require('rfdc')({ circles: true, proto: false })
const Ajv = require('ajv')
const { kSchemaController } = require('../lib/symbols.js')
const { FSTWRN001 } = require('../lib/warnings')
const { waitForCb } = require('./toolkit')
const echoParams = (req, reply) => { reply.send(req.params) }
const echoBody = (req, reply) => { reply.send(req.body) }
;['addSchema', 'getSchema', 'getSchemas', 'setValidatorCompiler', 'setSerializerCompiler'].forEach(f => {
test(`Should expose ${f} function`, t => {
t.plan(1)
const fastify = Fastify()
t.assert.strictEqual(typeof fastify[f], 'function')
})
})
;['setValidatorCompiler', 'setSerializerCompiler'].forEach(f => {
test(`cannot call ${f} after binding`, (t, testDone) => {
t.plan(2)
const fastify = Fastify()
t.after(() => fastify.close())
fastify.listen({ port: 0 }, err => {
t.assert.ifError(err)
try {
fastify[f](() => { })
t.assert.fail()
} catch (e) {
t.assert.ok(true)
testDone()
}
})
})
})
test('The schemas should be added to an internal storage', t => {
t.plan(1)
const fastify = Fastify()
const schema = { $id: 'id', my: 'schema' }
fastify.addSchema(schema)
t.assert.deepStrictEqual(fastify[kSchemaController].schemaBucket.store, { id: schema })
})
test('The schemas should be accessible via getSchemas', t => {
t.plan(1)
const fastify = Fastify()
const schemas = {
id: { $id: 'id', my: 'schema' },
abc: { $id: 'abc', my: 'schema' },
bcd: { $id: 'bcd', my: 'schema', properties: { a: 'a', b: 1 } }
}
Object.values(schemas).forEach(schema => { fastify.addSchema(schema) })
t.assert.deepStrictEqual(fastify.getSchemas(), schemas)
// ... (2139 more lines)
Domain
Subdomains
Functions
Classes
Source
Frequently Asked Questions
What does schema-feature.test.js do?
schema-feature.test.js is a source file in the fastify codebase, written in javascript. It belongs to the CoreKernel domain, LifecycleManager subdomain.
What functions are defined in schema-feature.test.js?
schema-feature.test.js defines 3 function(s): addRandomRoute, echoBody, echoParams.
Where is schema-feature.test.js in the architecture?
schema-feature.test.js is located at test/schema-feature.test.js (domain: CoreKernel, subdomain: LifecycleManager, directory: test).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free