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

const navigation = vi.hoisted(() => ({
  redirect: vi.fn((path: string) => {
    throw new Error(`NEXT_REDIRECT:${path}`)
  }),
}))

vi.mock('next/navigation', () => navigation)

import AdminRootPage from './page'

describe('admin public redirects', () => {
  it('sends the admin root to the login page', () => {
    expect(() => AdminRootPage()).toThrow('NEXT_REDIRECT:/login')
    expect(navigation.redirect).toHaveBeenCalledWith('/login')
  })
})
