/**
* Copyright (c) Paymium.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root of this projects source tree.
*/
import { render, fireEvent, screen } from '@crossed/test';
import { DayButton } from '../DayButton';
import { IDay } from '@crossed/use-calendar/src';
describe('DayButton', () => {
const mockDay: IDay = {
date: new Date(2025, 1, 15),
isToday: false,
isSelected: false,
isAdjacentMonth: false,
};
const mockOnPress = jest.fn();
test('renders correctly with given day', () => {
render();
expect(screen.getByText('15')).toBeInTheDocument();
});
test('calls onPress when clicked', () => {
render();
fireEvent.click(screen.getByRole('button'));
expect(mockOnPress).toHaveBeenCalled();
});
test('disables button if day is adjacent month', () => {
render(
);
expect(screen.getByRole('button')).toBeDisabled();
});
test('applies correct styles when day is today', () => {
render(
);
expect(screen.getByText('15')).toHaveStyle('borderWidth: 2');
});
test('applies correct styles when day is selected', () => {
render(
);
expect(screen.getByText('15')).toHaveClass(
'color-[var(--components--action-primary-default-text)]'
);
});
});