-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fixes #7 Signed-off-by: Matteo Collina <[email protected]> * fixup Signed-off-by: Matteo Collina <[email protected]> * fixup Signed-off-by: Matteo Collina <[email protected]> --------- Signed-off-by: Matteo Collina <[email protected]>
- Loading branch information
Showing
4 changed files
with
137 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { before, describe, it } from 'node:test' | ||
import Fastify from 'fastify' | ||
import asyncforge, { app, start } from '../index.js' | ||
import assert from 'node:assert/strict' | ||
|
||
let fastify | ||
|
||
async function build (config) { | ||
const server = await Fastify() | ||
|
||
server.decorate('config', config) | ||
await start(server) | ||
|
||
return server | ||
} | ||
|
||
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' }) | ||
}) | ||
|
||
it('throws', () => { | ||
assert.throws(app) | ||
}) | ||
|
||
it('does not throw using enterWith', () => { | ||
fastify.enterWith() | ||
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) | ||
}) | ||
}) |