Aktueller Stand
This commit is contained in:
22
backend/node_modules/fastify/test/handler-context.test.js
generated
vendored
22
backend/node_modules/fastify/test/handler-context.test.js
generated
vendored
@@ -1,7 +1,7 @@
|
||||
'use strict'
|
||||
const test = require('tap').test
|
||||
const { test } = require('node:test')
|
||||
const { kRouteContext } = require('../lib/symbols')
|
||||
const fastify = require('../')
|
||||
const fastify = require('..')
|
||||
|
||||
test('handlers receive correct `this` context', async (t) => {
|
||||
t.plan(4)
|
||||
@@ -17,15 +17,15 @@ test('handlers receive correct `this` context', async (t) => {
|
||||
instance.register(plugin)
|
||||
|
||||
instance.get('/', function (req, reply) {
|
||||
t.ok(this.foo)
|
||||
t.equal(this.foo, 'foo')
|
||||
t.assert.ok(this.foo)
|
||||
t.assert.strictEqual(this.foo, 'foo')
|
||||
reply.send()
|
||||
})
|
||||
|
||||
await instance.inject('/')
|
||||
|
||||
t.ok(instance.foo)
|
||||
t.equal(instance.foo, 'foo')
|
||||
t.assert.ok(instance.foo)
|
||||
t.assert.strictEqual(instance.foo, 'foo')
|
||||
})
|
||||
|
||||
test('handlers have access to the internal context', async (t) => {
|
||||
@@ -33,11 +33,11 @@ test('handlers have access to the internal context', async (t) => {
|
||||
|
||||
const instance = fastify()
|
||||
instance.get('/', { config: { foo: 'bar' } }, function (req, reply) {
|
||||
t.ok(reply[kRouteContext])
|
||||
t.ok(reply[kRouteContext].config)
|
||||
t.type(reply[kRouteContext].config, Object)
|
||||
t.ok(reply[kRouteContext].config.foo)
|
||||
t.equal(reply[kRouteContext].config.foo, 'bar')
|
||||
t.assert.ok(reply[kRouteContext])
|
||||
t.assert.ok(reply[kRouteContext].config)
|
||||
t.assert.ok(typeof reply[kRouteContext].config, Object)
|
||||
t.assert.ok(reply[kRouteContext].config.foo)
|
||||
t.assert.strictEqual(reply[kRouteContext].config.foo, 'bar')
|
||||
reply.send()
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user