Aktueller Stand
This commit is contained in:
52
backend/node_modules/avvio/test/express.test.js
generated
vendored
52
backend/node_modules/avvio/test/express.test.js
generated
vendored
@@ -1,52 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
const { test } = require('tap')
|
||||
const express = require('express')
|
||||
const http = require('node:http')
|
||||
const boot = require('..')
|
||||
|
||||
test('express support', (t) => {
|
||||
const app = express()
|
||||
|
||||
boot.express(app)
|
||||
// It does:
|
||||
//
|
||||
// boot(app, {
|
||||
// expose: {
|
||||
// use: 'load'
|
||||
// }
|
||||
// })
|
||||
|
||||
t.plan(2)
|
||||
|
||||
let loaded = false
|
||||
let server
|
||||
|
||||
app.load(function (app, opts, done) {
|
||||
loaded = true
|
||||
app.use(function (req, res) {
|
||||
res.end('hello world')
|
||||
})
|
||||
|
||||
done()
|
||||
})
|
||||
|
||||
app.after((cb) => {
|
||||
t.ok(loaded, 'plugin loaded')
|
||||
server = app.listen(0, cb)
|
||||
t.teardown(server.close.bind(server))
|
||||
})
|
||||
|
||||
app.ready(() => {
|
||||
http.get(`http://localhost:${server.address().port}`).on('response', function (res) {
|
||||
let data = ''
|
||||
res.on('data', function (chunk) {
|
||||
data += chunk
|
||||
})
|
||||
|
||||
res.on('end', function () {
|
||||
t.equal(data, 'hello world')
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
8
backend/node_modules/avvio/test/lib/thenify.test.js
generated
vendored
8
backend/node_modules/avvio/test/lib/thenify.test.js
generated
vendored
@@ -1,6 +1,6 @@
|
||||
'use strict'
|
||||
|
||||
const { test, mock } = require('tap')
|
||||
const { test, mockRequire } = require('tap')
|
||||
const { kThenifyDoNotWrap } = require('../../lib/symbols')
|
||||
|
||||
test('thenify', (t) => {
|
||||
@@ -9,7 +9,7 @@ test('thenify', (t) => {
|
||||
t.test('return undefined if booted', (t) => {
|
||||
t.plan(2)
|
||||
|
||||
const { thenify } = mock('../../lib/thenify', {
|
||||
const { thenify } = mockRequire('../../lib/thenify', {
|
||||
'../../lib/debug': {
|
||||
debug: (message) => { t.equal(message, 'thenify returning undefined because we are already booted') }
|
||||
}
|
||||
@@ -33,7 +33,7 @@ test('thenify', (t) => {
|
||||
t.test('return PromiseConstructorLike if kThenifyDoNotWrap is false', (t) => {
|
||||
t.plan(3)
|
||||
|
||||
const { thenify } = mock('../../lib/thenify', {
|
||||
const { thenify } = mockRequire('../../lib/thenify', {
|
||||
'../../lib/debug': {
|
||||
debug: (message) => { t.equal(message, 'thenify') }
|
||||
}
|
||||
@@ -49,7 +49,7 @@ test('thenify', (t) => {
|
||||
t.test('return PromiseConstructorLike', (t) => {
|
||||
t.plan(3)
|
||||
|
||||
const { thenify } = mock('../../lib/thenify', {
|
||||
const { thenify } = mockRequire('../../lib/thenify', {
|
||||
'../../lib/debug': {
|
||||
debug: (message) => { t.equal(message, 'thenify') }
|
||||
}
|
||||
|
||||
11
backend/node_modules/avvio/test/load-plugin.test.js
generated
vendored
11
backend/node_modules/avvio/test/load-plugin.test.js
generated
vendored
@@ -31,6 +31,17 @@ test('catch an error when loading a plugin with sync function', (t) => {
|
||||
})
|
||||
})
|
||||
|
||||
test('successfully load a plugin with sync function without done as a parameter', (t) => {
|
||||
t.plan(1)
|
||||
const app = boot({})
|
||||
|
||||
const plugin = new Plugin(fastq(app, app._loadPluginNextTick, 1), function (instance, opts) { }, false, 0)
|
||||
|
||||
app._loadPlugin(plugin, function (err) {
|
||||
t.equal(err, undefined)
|
||||
})
|
||||
})
|
||||
|
||||
test('successfully load a plugin with async function', (t) => {
|
||||
t.plan(1)
|
||||
const app = boot({})
|
||||
|
||||
18
backend/node_modules/avvio/test/no-done.test.js
generated
vendored
Normal file
18
backend/node_modules/avvio/test/no-done.test.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
'use strict'
|
||||
|
||||
const { test } = require('tap')
|
||||
const boot = require('..')
|
||||
|
||||
test('not taking done does not throw error.', (t) => {
|
||||
t.plan(2)
|
||||
|
||||
const app = boot()
|
||||
|
||||
app.use(noDone).ready((err) => {
|
||||
t.notOk(err, 'no error')
|
||||
})
|
||||
|
||||
function noDone (s, opts) {
|
||||
t.pass('did not throw')
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user