import { composeStories } from "@storybook/react";
import { render, screen } from "@testing-library/react";
import { describe, expect, it } from "vitest";
import * as calendarStories from "./Calendar.stories";

const { Default, WithEvents, MonthView, WeekView, DayView, EmptyCalendar } =
	composeStories(calendarStories);

describe("Calendar stories", () => {
	describe("Default story", () => {
		it("should render calendar with month view", () => {
			render(<Default />);
			expect(screen.getByText("Today")).toBeInTheDocument();
			expect(screen.getByText("Month")).toBeInTheDocument();
			expect(screen.getByText("Week")).toBeInTheDocument();
			expect(screen.getByText("Day")).toBeInTheDocument();
		});

		it("should render day headers", () => {
			render(<Default />);
			expect(screen.getByText("Sun")).toBeInTheDocument();
			expect(screen.getByText("Mon")).toBeInTheDocument();
			expect(screen.getByText("Tue")).toBeInTheDocument();
			expect(screen.getByText("Wed")).toBeInTheDocument();
			expect(screen.getByText("Thu")).toBeInTheDocument();
			expect(screen.getByText("Fri")).toBeInTheDocument();
			expect(screen.getByText("Sat")).toBeInTheDocument();
		});
	});

	describe("WithEvents story", () => {
		it("should render calendar with events", () => {
			render(<WithEvents />);
			expect(screen.getByText("Team Meeting")).toBeInTheDocument();
			expect(screen.getByText("Project Review")).toBeInTheDocument();
			expect(screen.getByText("Client Presentation")).toBeInTheDocument();
		});

		it("should render navigation controls", () => {
			render(<WithEvents />);
			expect(screen.getByText("Today")).toBeInTheDocument();
		});
	});

	describe("MonthView story", () => {
		it("should render month view", () => {
			render(<MonthView />);
			expect(screen.getByText("Month")).toBeInTheDocument();
			expect(screen.getByText("Today")).toBeInTheDocument();
		});
	});

	describe("WeekView story", () => {
		it("should render week view", () => {
			render(<WeekView />);
			expect(screen.getByText("Week")).toBeInTheDocument();
			expect(screen.getByText("Today")).toBeInTheDocument();
		});
	});

	describe("DayView story", () => {
		it("should render day view", () => {
			render(<DayView />);
			expect(screen.getByText("Day")).toBeInTheDocument();
			expect(screen.getByText("Today")).toBeInTheDocument();
		});
	});

	describe("EmptyCalendar story", () => {
		it("should render empty calendar", () => {
			render(<EmptyCalendar />);
			expect(screen.getByText("Today")).toBeInTheDocument();
			expect(screen.getByText("Month")).toBeInTheDocument();
		});
	});
});
