import { describe, it, expect, vi, beforeEach } from 'vitest'
import { mount } from '@vue/test-utils'
import LandingHero from '../LandingHero.vue'

const { pushMock } = vi.hoisted(() => ({
  pushMock: vi.fn(),
}))

vi.mock('vue-router', () => ({
  useRouter: vi.fn(() => ({ push: pushMock })),
}))

describe('LandingHero.vue', () => {
  beforeEach(() => {
    vi.clearAllMocks()
  })

  it('renders the logo image', () => {
    const wrapper = mount(LandingHero)
    const logo = wrapper.find('img.hero-logo')
    expect(logo.exists()).toBe(true)
    expect(logo.attributes('src')).toBe('/images/full_logo.png')
  })

  it('renders a tagline', () => {
    const wrapper = mount(LandingHero)
    expect(wrapper.find('.hero-tagline').exists()).toBe(true)
  })

  it('renders Sign In and Get Started buttons', () => {
    const wrapper = mount(LandingHero)
    const buttons = wrapper.findAll('button')
    expect(buttons).toHaveLength(2)
    expect(buttons[0].text()).toBe('Sign In')
    expect(buttons[1].text()).toBe('Get Started Free')
  })

  it('navigates to Login route when Sign In is clicked', async () => {
    const wrapper = mount(LandingHero)
    await wrapper.find('.btn-hero-signin').trigger('click')
    expect(pushMock).toHaveBeenCalledWith({ name: 'Login' })
  })

  it('navigates to Signup route when Get Started is clicked', async () => {
    const wrapper = mount(LandingHero)
    await wrapper.find('.btn-hero-signup').trigger('click')
    expect(pushMock).toHaveBeenCalledWith({ name: 'Signup' })
  })
})
