mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
95 lines
3.1 KiB
TypeScript
95 lines
3.1 KiB
TypeScript
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
|
import { Connection } from '@dbTools/typeorm'
|
|
import { Community as DbCommunity } from '@entity/Community'
|
|
import { User as DbUser } from '@entity/User'
|
|
import { ApolloServerTestClient } from 'apollo-server-testing'
|
|
|
|
import { cleanDB, testEnvironment } from '@test/helpers'
|
|
|
|
import { writeHomeCommunityEntry } from '@/seeds/community'
|
|
import { userFactory } from '@/seeds/factory/user'
|
|
import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg'
|
|
import { bobBaumeister } from '@/seeds/users/bob-baumeister'
|
|
import { peterLustig } from '@/seeds/users/peter-lustig'
|
|
|
|
import { findUserByIdentifier } from './findUserByIdentifier'
|
|
|
|
let con: Connection
|
|
let testEnv: {
|
|
mutate: ApolloServerTestClient['mutate']
|
|
query: ApolloServerTestClient['query']
|
|
con: Connection
|
|
}
|
|
|
|
beforeAll(async () => {
|
|
testEnv = await testEnvironment()
|
|
con = testEnv.con
|
|
await cleanDB()
|
|
})
|
|
|
|
afterAll(async () => {
|
|
await cleanDB()
|
|
await con.close()
|
|
})
|
|
|
|
describe('graphql/resolver/util/findUserByIdentifier', () => {
|
|
let homeCom: DbCommunity
|
|
let communityUuid: string
|
|
let communityName: string
|
|
let userBibi: DbUser
|
|
|
|
beforeAll(async () => {
|
|
homeCom = await writeHomeCommunityEntry()
|
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
communityUuid = homeCom.communityUuid!
|
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
communityName = homeCom.communityUuid!
|
|
|
|
userBibi = await userFactory(testEnv, bibiBloxberg)
|
|
await userFactory(testEnv, peterLustig)
|
|
await userFactory(testEnv, bobBaumeister)
|
|
})
|
|
|
|
describe('communityIdentifier is community uuid', () => {
|
|
it('userIdentifier is gradido id', async () => {
|
|
const user = await findUserByIdentifier(userBibi.gradidoID, communityUuid)
|
|
user.userRoles = []
|
|
expect(user).toMatchObject(userBibi)
|
|
})
|
|
|
|
it('userIdentifier is alias', async () => {
|
|
const user = await findUserByIdentifier(userBibi.alias, communityUuid)
|
|
user.userRoles = []
|
|
expect(user).toMatchObject(userBibi)
|
|
})
|
|
|
|
it('userIdentifier is email', async () => {
|
|
const user = await findUserByIdentifier(userBibi.emailContact.email, communityUuid)
|
|
user.userRoles = []
|
|
expect(user).toMatchObject(userBibi)
|
|
})
|
|
})
|
|
|
|
describe('communityIdentifier is community name', () => {
|
|
it('userIdentifier is gradido id', async () => {
|
|
const user = await findUserByIdentifier(userBibi.gradidoID, communityName)
|
|
user.userRoles = []
|
|
expect(user).toMatchObject(userBibi)
|
|
})
|
|
|
|
it('userIdentifier is alias', async () => {
|
|
const user = await findUserByIdentifier(userBibi.alias, communityName)
|
|
user.userRoles = []
|
|
expect(user).toMatchObject(userBibi)
|
|
})
|
|
|
|
it('userIdentifier is email', async () => {
|
|
const user = await findUserByIdentifier(userBibi.emailContact.email, communityName)
|
|
user.userRoles = []
|
|
expect(user).toMatchObject(userBibi)
|
|
})
|
|
})
|
|
})
|