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 "./Switch.stories"

const { Default, Disabled } = composeStories(stories)

describe("<Switch />", () => {
  test("Default", async () => {
    render(<Default />)

    const toggle = await screen.findByRole("switch")

    expect(toggle).not.toBeChecked()

    await userEvent.click(toggle)

    expect(toggle).toBeChecked()
  })

  test("Disabled", async () => {
    render(<Disabled />)

    const toggle = await screen.findByRole("switch")

    expect(toggle).toBeDisabled()
  })
})
