chore: scaffold node/ts/vitest project with health endpoint
This commit is contained in:
23
server/test/app.test.ts
Normal file
23
server/test/app.test.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { buildApp } from '../src/app.js'
|
||||
import { openDatabase } from '../src/db.js'
|
||||
import type { Config } from '../src/config.js'
|
||||
|
||||
const config: Config = {
|
||||
dataDir: ':memory:',
|
||||
artworkDir: ':memory:',
|
||||
dbPath: ':memory:',
|
||||
port: 0,
|
||||
sessionSecret: 'test-secret-test-secret-test-secret-1234',
|
||||
}
|
||||
|
||||
describe('GET /api/health', () => {
|
||||
it('returns ok', async () => {
|
||||
const db = openDatabase(':memory:')
|
||||
const app = await buildApp({ db, config })
|
||||
const res = await app.inject({ method: 'GET', url: '/api/health' })
|
||||
expect(res.statusCode).toBe(200)
|
||||
expect(res.json()).toEqual({ ok: true })
|
||||
await app.close()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user