import { beforeEach, describe, expect, it, vi } from 'vitest'

vi.mock('../../lib/prisma', () => ({
  prisma: {
    adminUser: {
      findFirst: vi.fn(),
    },
  },
}))

import { prisma } from '../../lib/prisma'
import { findAdminByEmail } from './admin.repo'

describe('admin.repo', () => {
  beforeEach(() => {
    vi.clearAllMocks()
  })

  it('looks up admin email case-insensitively', async () => {
    await findAdminByEmail('Admin@Example.com')

    expect(prisma.adminUser.findFirst).toHaveBeenCalledWith({
      where: {
        email: {
          equals: 'Admin@Example.com',
          mode: 'insensitive',
        },
      },
    })
  })
})
