Skip to content

Commit

Permalink
Update testHelper.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
aelassas committed Nov 18, 2024
1 parent 5e032a9 commit 1cb3a21
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions api/tests/testHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,17 @@ export const initialize = async () => {
expect(admin.id).toBeDefined()
ADMIN_USER_ID = admin.id

const adminFromEnv = await User.findOne({ email: env.ADMIN_EMAIL })
if (env.ADMIN_EMAIL && !adminFromEnv) {
await (new User({
fullName: 'admin',
email: env.ADMIN_EMAIL,
language: LANGUAGE,
password: passwordHash,
type: bookcarsTypes.UserType.Admin,
})).save()
if (env.ADMIN_EMAIL) {
const adminFromEnv = await User.findOne({ email: env.ADMIN_EMAIL })
if (!adminFromEnv) {
await (new User({
fullName: 'admin',
email: env.ADMIN_EMAIL,
language: LANGUAGE,
password: passwordHash,
type: bookcarsTypes.UserType.Admin,
})).save()
}
}

// user
Expand Down

0 comments on commit 1cb3a21

Please sign in to comment.