Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
Signed-off-by: Matteo Collina <[email protected]>
  • Loading branch information
mcollina committed Apr 23, 2024
1 parent 57cfd73 commit dd2aba1
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions test/issue-7.test.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { before, describe, it } from 'node:test'
import Fastify from 'fastify'
import { app, start } from '../index.js'
import asyncforge, { app, start } from '../index.js'
import assert from 'node:assert/strict'

let fastify
Expand All @@ -14,7 +14,16 @@ async function build (config) {
return server
}

describe('support exiting from a context', () => {
async function buildWithRegister (config) {
const server = await Fastify()

server.register(asyncforge)
server.decorate('config', config)

return server
}

describe('support exiting from a context / start', () => {
before(async () => {
fastify = await build({ foo: 'bar' })
})
Expand All @@ -28,3 +37,18 @@ describe('support exiting from a context', () => {
assert.equal(app(), fastify)
})
})

describe('support exiting from a context / register', () => {
before(async () => {
fastify = await buildWithRegister({ foo: 'bar' })
})

it('throws', () => {
assert.throws(app)
})

it('does not throw using enterWith', () => {
fastify.enterWith()
assert.equal(app(), fastify)
})
})

0 comments on commit dd2aba1

Please sign in to comment.