Member registration fixed
This commit is contained in:
36
tests/membership-applications.spec.ts
Normal file
36
tests/membership-applications.spec.ts
Normal 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 })
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user