admin/components/events/schedule/EventScheduleFieldControl.wheels.test.tsx
alisaza e1eaf5eff5 feat: initial ghabilee-admin backoffice app
Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js
app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
2026-09-05 13:12:59 +03:30

42 lines
1.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { cleanup, render } from '@testing-library/react'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { DateWheel, TimeWheel } from '@/components/events/schedule/EventScheduleFieldControl'
afterEach(cleanup)
describe('Event schedule wheels', () => {
it('renders the date wheel with Figma typography and a slash divider', () => {
const { container, getByText } = render(
<DateWheel
minDate={new Date(2025, 0, 1)}
value={{ day: '27', month: '5', year: '1404' }}
onChange={vi.fn()}
/>
)
expect(getByText('/')).toHaveClass('text-xl', 'font-semibold')
expect(getByText('مرداد')).toHaveAttribute('data-selected', 'true')
expect(getByText('مرداد')).toHaveClass('text-xl', 'font-semibold', 'text-consumer-text')
expect(getByText('تیر')).toHaveClass('text-lg', 'text-secondary-40')
expect(container.querySelector('.consumer-wheel-picker')).toBeInTheDocument()
})
it('renders the time wheel with unpadded values and a colon divider', () => {
const { container, getByText } = render(
<TimeWheel
minValue={0}
value={{ hour: '10', minute: '0' }}
onChange={vi.fn()}
/>
)
expect(getByText(':')).toHaveClass('text-xl', 'font-semibold')
const selectedItems = Array.from(container.querySelectorAll('[data-selected="true"]'))
expect(selectedItems.map((item) => item.textContent)).toEqual(['۱۰', '۰'])
expect(selectedItems.every((item) => item.classList.contains('text-xl'))).toBe(true)
})
})