-
-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
suggestion: await engine to support inline engine import in options (#…
…422) * await engine to support inline engine import in options * add test for using engine imported as promise * configure tap in .taprc only, and remove logging from the new test
- Loading branch information
1 parent
ffe8fe6
commit 8a78eb9
Showing
3 changed files
with
34 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ coverage: true | |
nyc-arg: [--exclude=out] | ||
|
||
files: | ||
- test/**/*.js | ||
- test/**/*.{js,mjs} |
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,32 @@ | ||
import t from 'tap' | ||
import get from 'simple-get' | ||
import Fastify from 'fastify' | ||
import fs from 'node:fs' | ||
const test = t.test | ||
const sget = get.concat | ||
|
||
test('using an imported engine as a promise', t => { | ||
t.plan(3) | ||
const fastify = Fastify() | ||
const data = { text: 'text' } | ||
const ejs = import('ejs') | ||
|
||
fastify.register(import('../index.js'), { engine: { ejs }, templates: 'templates' }) | ||
|
||
fastify.get('/', (req, reply) => { | ||
reply.view('index.ejs', data) | ||
}) | ||
|
||
fastify.listen({ port: 0 }, err => { | ||
t.error(err) | ||
|
||
sget({ | ||
method: 'GET', | ||
url: 'http://localhost:' + fastify.server.address().port | ||
}, async (err, response, body) => { | ||
t.error(err) | ||
t.equal((await ejs).render(fs.readFileSync('./templates/index.ejs', 'utf8'), data), body.toString()) | ||
fastify.close() | ||
}) | ||
}) | ||
}) |