Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/calendar buttons #1460

Merged
merged 8 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/loud-months-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@alfalab/core-components-calendar': minor
---

Добавлены пропсы для передачи кастомного текста в кнопки мобильного календаря
91 changes: 90 additions & 1 deletion packages/calendar/src/Component.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { render, fireEvent, renderHook } from '@testing-library/react';
import { render, fireEvent, renderHook, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import subDays from 'date-fns/subDays';
import addDays from 'date-fns/addDays';
Expand Down Expand Up @@ -1436,3 +1436,92 @@ describe('hook tests', () => {
expect(result.current.selectedTo).toBe(initialDate);
});
});

describe('CalendarMobile buttons content', () => {
it('should pass default range select button text', () => {
render(
<CalendarMobile open={true} selectedFrom={1708376400000} selectedTo={1708549200000} />,
);

const text = screen.getByText('Выбрать');

expect(text).toBeInTheDocument();
});

it('should pass default range reset button text', () => {
render(
<CalendarMobile open={true} selectedFrom={1708376400000} selectedTo={1708549200000} />,
);

const text = screen.getByText('Сбросить');

expect(text).toBeInTheDocument();
});
it('should pass range select button text', () => {
render(
<CalendarMobile
open={true}
selectedFrom={1708376400000}
selectedTo={1708549200000}
selectButtonContent={'selectButtonContent'}
/>,
);

const text = screen.getByText('selectButtonContent');

expect(text).toBeInTheDocument();
});

it('should pass range reset button text', () => {
render(
<CalendarMobile
open={true}
selectedFrom={1708376400000}
selectedTo={1708549200000}
resetButtonContent={'resetButtonContent'}
/>,
);

const text = screen.getByText('resetButtonContent');

expect(text).toBeInTheDocument();
});

it('should pass default select button text', () => {
render(<CalendarMobile open={true} value={1708376400000} />);

const text = screen.getByText('Выбрать');

expect(text).toBeInTheDocument();
});

it('should pass select button text', () => {
render(
<CalendarMobile
open={true}
value={1708376400000}
selectButtonContent={'selectButtonContent'}
/>,
);

const text = screen.getByText('selectButtonContent');

expect(text).toBeInTheDocument();
});

it('should pass default cancel button text', () => {
render(<CalendarMobile open={true} />);

const text = screen.getByText('Отмена');

expect(text).toBeInTheDocument();
});

it('should pass cancel button text', () => {
render(<CalendarMobile open={true} cancelButtonContent={'cancelButtonContent'} />);

const text = screen.getByText('cancelButtonContent');

expect(text).toBeInTheDocument();
});
});
Loading
Loading