Member registration fixed
Some checks failed
Code Analysis and Production Deploy / analyze (push) Failing after 6m17s
Code Analysis and Production Deploy / deploy-production (push) Has been skipped
Code Analysis and Production Deploy / deploy-test (push) Has been skipped

This commit is contained in:
Torsten Schulz (local)
2026-08-12 11:15:07 +02:00
parent 281c25b05d
commit cb89fdd911
15 changed files with 263 additions and 41 deletions

View File

@@ -0,0 +1,36 @@
import { afterEach, describe, expect, it, vi } from 'vitest'
import { promises as fs } from 'fs'
import os from 'os'
import path from 'path'
const originalAppRoot = process.env.APP_ROOT
const createdRoots = []
afterEach(async () => {
vi.resetModules()
if (originalAppRoot === undefined) delete process.env.APP_ROOT
else process.env.APP_ROOT = originalAppRoot
await Promise.all(createdRoots.splice(0).map(root => fs.rm(root, { recursive: true, force: true })))
})
describe('membership applications', () => {
it('rejects a second pending application with the same name and birth date', async () => {
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'harheimertc-membership-'))
createdRoots.push(root)
await fs.mkdir(path.join(root, 'server', 'data'), { recursive: true })
process.env.APP_ROOT = root
const { createMembershipApplication } = await import('../server/utils/membership-applications.js')
const data = {
vorname: 'Jörg',
nachname: 'Beispiel',
geburtsdatum: '1990-02-03',
mitgliedschaftsart: 'aktiv'
}
const application = await createMembershipApplication(data)
expect(application.status).toBe('pending')
await expect(createMembershipApplication({ ...data, vorname: ' JÖRG ' }))
.rejects.toMatchObject({ statusCode: 409 })
})
})