strong-tie/inbound-calls
0
1'use strict'2 3const { test } = require('node:test')4const Fastify = require('..')5 6test('sync route', async t => {7 const fastify = Fastify()8 t.after(() => fastify.close())9 fastify.get('/', () => 'hello world')10 const res = await fastify.inject('/')11 t.assert.strictEqual(res.statusCode, 200)12 t.assert.strictEqual(res.body, 'hello world')13})14 15test('sync route return null', async t => {16 const fastify = Fastify()17 t.after(() => fastify.close())18 fastify.get('/', () => null)19 const res = await fastify.inject('/')20 t.assert.strictEqual(res.statusCode, 200)21 t.assert.strictEqual(res.body, 'null')22})23 24test('sync route, error', async t => {25 const fastify = Fastify()26 t.after(() => fastify.close())27 fastify.get('/', () => {28 throw new Error('kaboom')29 })30 const res = await fastify.inject('/')31 t.assert.strictEqual(res.statusCode, 500)32})33 