import { composeStories } from "@storybook/react"
import { screen } from "@testing-library/react"
import { userEvent } from "@testing-library/user-event"
import React from "react"
import { expect, describe, test } from "vitest"
import { render } from "../../../tests/render"
import * as stories from "./ToggleButton.stories"

const { Default } = composeStories(stories)

describe("<ToggleButton />", () => {
  test("Default", async () => {
    render(<Default />)
    const button = await screen.findByRole("checkbox")

    expect(button).not.toHaveAttribute("aria-checked")

    await userEvent.click(button)

    expect(button).toHaveAttribute("aria-checked", "true")
  })
})
