mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
- Fix the sending of the multiple times registrars name to the email owner. - Clarify the logging of the multiple times registrars name and the email owners name.
50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||
|
||
import { createTestClient } from 'apollo-server-testing'
|
||
import createServer from '../src/server/createServer'
|
||
import { initialize } from '@dbTools/helpers'
|
||
import { entities } from '@entity/index'
|
||
|
||
export const headerPushMock = jest.fn((t) => {
|
||
context.token = t.value
|
||
})
|
||
|
||
const context = {
|
||
token: '',
|
||
setHeaders: {
|
||
push: headerPushMock,
|
||
forEach: jest.fn(),
|
||
},
|
||
}
|
||
|
||
export const cleanDB = async () => {
|
||
// this only works as lond we do not have foreign key constraints
|
||
for (let i = 0; i < entities.length; i++) {
|
||
await resetEntity(entities[i])
|
||
}
|
||
}
|
||
|
||
export const testEnvironment = async (logger?: any, localization?: any) => {
|
||
// Wolle: console.log('testEnvironment – localization: ', localization)
|
||
const server = await createServer(context, logger, localization)
|
||
const con = server.con
|
||
const testClient = createTestClient(server.apollo)
|
||
const mutate = testClient.mutate
|
||
const query = testClient.query
|
||
await initialize()
|
||
return { mutate, query, con }
|
||
}
|
||
|
||
export const resetEntity = async (entity: any) => {
|
||
const items = await entity.find({ withDeleted: true })
|
||
if (items.length > 0) {
|
||
const ids = items.map((i: any) => i.id)
|
||
await entity.delete(ids)
|
||
}
|
||
}
|
||
|
||
export const resetToken = () => {
|
||
context.token = ''
|
||
}
|