import { describe, it, expect } from 'vitest'
import { render, screen, fireEvent } from '@testing-library/svelte'
import Counter from './Counter.svelte'

describe('Counter', () => {
  it('starts at 0 and increments on click', async () => {
    render(Counter)
    const btn = screen.getByRole('button', { name: /count is 0/i })
    expect(btn).toBeInTheDocument()
    await fireEvent.click(btn)
    expect(screen.getByRole('button', { name: /count is 1/i })).toBeInTheDocument()
    await fireEvent.click(screen.getByRole('button', { name: /count is 1/i }))
    expect(screen.getByRole('button', { name: /count is 2/i })).toBeInTheDocument()
  })
})
