update(wip): I want to docker commit myself
This commit is contained in:
parent
f9671ea198
commit
68f8d87477
43 changed files with 557 additions and 2915 deletions
43
src/icons/test/helper.ts
Normal file
43
src/icons/test/helper.ts
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
// This file contains code that we reuse between our tests.
|
||||
import helper from 'fastify-cli/helper.js'
|
||||
import * as test from 'node:test'
|
||||
import * as path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
export type TestContext = {
|
||||
after: typeof test.after
|
||||
}
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url)
|
||||
const __dirname = path.dirname(__filename)
|
||||
const AppPath = path.join(__dirname, '..', 'src', 'app.ts')
|
||||
|
||||
// Fill in this config with all the configurations
|
||||
// needed for testing the application
|
||||
function config () {
|
||||
return {
|
||||
skipOverride: true // Register our application with fastify-plugin
|
||||
}
|
||||
}
|
||||
|
||||
// Automatically build and tear down our instance
|
||||
async function build (t: TestContext) {
|
||||
// you can set all the options supported by the fastify CLI command
|
||||
const argv = [AppPath]
|
||||
|
||||
// fastify-plugin ensures that all decorators
|
||||
// are exposed for testing purposes, this is
|
||||
// different from the production setup
|
||||
const app = await helper.build(argv, config())
|
||||
|
||||
// Tear down our app after we are done
|
||||
// eslint-disable-next-line no-void
|
||||
t.after(() => void app.close())
|
||||
|
||||
return app
|
||||
}
|
||||
|
||||
export {
|
||||
config,
|
||||
build
|
||||
}
|
||||
13
src/icons/test/plugins/support.test.ts
Normal file
13
src/icons/test/plugins/support.test.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import { test } from 'node:test'
|
||||
import * as assert from 'node:assert'
|
||||
import Fastify from 'fastify'
|
||||
import Support from '../../src/plugins/support.js'
|
||||
|
||||
test('support works standalone', async (t) => {
|
||||
const fastify = Fastify()
|
||||
// eslint-disable-next-line no-void
|
||||
void fastify.register(Support)
|
||||
await fastify.ready()
|
||||
|
||||
assert.equal(fastify.someSupport(), 'hugs')
|
||||
})
|
||||
13
src/icons/test/routes/example.test.ts
Normal file
13
src/icons/test/routes/example.test.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import { test } from 'node:test'
|
||||
import * as assert from 'node:assert'
|
||||
import { build } from '../helper.js'
|
||||
|
||||
test('example is loaded', async (t) => {
|
||||
const app = await build(t)
|
||||
|
||||
const res = await app.inject({
|
||||
url: '/example'
|
||||
})
|
||||
|
||||
assert.equal(res.payload, 'this is an example')
|
||||
})
|
||||
12
src/icons/test/routes/root.test.ts
Normal file
12
src/icons/test/routes/root.test.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import { test } from 'node:test'
|
||||
import * as assert from 'node:assert'
|
||||
import { build } from '../helper.js'
|
||||
|
||||
test('default root route', async (t) => {
|
||||
const app = await build(t)
|
||||
|
||||
const res = await app.inject({
|
||||
url: '/'
|
||||
})
|
||||
assert.deepStrictEqual(JSON.parse(res.payload), { root: true })
|
||||
})
|
||||
8
src/icons/test/tsconfig.json
Normal file
8
src/icons/test/tsconfig.json
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"noEmit": false
|
||||
},
|
||||
"include": ["../src/**/*.ts", "**/*.ts"]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue