mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
pass ApolloServerTestClient as first argument of factories
This commit is contained in:
parent
c7e3d3d224
commit
7e645e08fa
@ -1,13 +1,16 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
|
||||
import { createUser, setPassword } from '@/seeds/graphql/mutations'
|
||||
import { User } from '@entity/User'
|
||||
import { LoginEmailOptIn } from '@entity/LoginEmailOptIn'
|
||||
import { ServerUser } from '@entity/ServerUser'
|
||||
import { UserInterface } from '@/seeds/users/UserInterface'
|
||||
import { ApolloServerTestClient } from 'apollo-server-testing'
|
||||
|
||||
export const userFactory = async (
|
||||
client: ApolloServerTestClient,
|
||||
user: UserInterface,
|
||||
): Promise<void> => {
|
||||
const { mutate } = client
|
||||
|
||||
export const createUserFactory = async (mutate: any, user: UserInterface): Promise<void> => {
|
||||
await mutate({ mutation: createUser, variables: user })
|
||||
let dbUser = await User.findOneOrFail({ where: { email: user.email } })
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ import { createTestClient } from 'apollo-server-testing'
|
||||
import { name, internet, random } from 'faker'
|
||||
|
||||
import { users } from './users/index'
|
||||
import { createUserFactory } from './factory/user'
|
||||
import { userFactory } from './factory/user'
|
||||
import { entities } from '@entity/index'
|
||||
|
||||
const context = {
|
||||
@ -39,18 +39,17 @@ const resetEntity = async (entity: any) => {
|
||||
const run = async () => {
|
||||
const server = await createServer(context)
|
||||
const testClient = createTestClient(server.apollo)
|
||||
const { mutate } = testClient
|
||||
const { con } = server
|
||||
await cleanDB()
|
||||
|
||||
// seed the standard users
|
||||
for (let i = 0; i < users.length; i++) {
|
||||
await createUserFactory(mutate, users[i])
|
||||
await userFactory(testClient, users[i])
|
||||
}
|
||||
|
||||
// seed 100 random users
|
||||
for (let i = 0; i < 100; i++) {
|
||||
await createUserFactory(mutate, {
|
||||
await userFactory(testClient, {
|
||||
firstName: name.firstName(),
|
||||
lastName: name.lastName(),
|
||||
email: internet.email(),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user