Skip to content

Commit

Permalink
feat: add test cases to date range picker
Browse files Browse the repository at this point in the history
  • Loading branch information
brunomous committed Dec 24, 2024
1 parent a174cb0 commit 933f10c
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions packages/react-material-ui/__tests__/DateRangePicker.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@

import '@testing-library/jest-dom';
import React from 'react';
import { render, fireEvent, getByRole } from '@testing-library/react';
import {
LocalizationProvider,
MuiPickersAdapter,
MuiPickersAdapterContext,
} from '@mui/x-date-pickers';
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
import { render } from '@testing-library/react';
import DateRangePicker from '../src/components/DateRangePicker';

describe('DateRangePicker Component', () => {
Expand Down Expand Up @@ -46,4 +40,21 @@ describe('DateRangePicker Component', () => {
expect(startDateInput).toBeInTheDocument();
expect(endDateInput).toBeInTheDocument();
});

test('should set input values when prop is passed', () => {
const { getByTestId } = render(
<DateRangePicker
label="Date Range"
value={{
startDate: new Date('2024-12-10T18:34:37.172Z'),
endDate: new Date('2025-01-08T18:34:37.172Z'),
}}
/>,
);
const startDateInput = getByTestId('start-date-input');
const endDateInput = getByTestId('end-date-input');

expect(startDateInput).toHaveValue('2024-12-10');
expect(endDateInput).toHaveValue('2025-01-08');
});
});

0 comments on commit 933f10c

Please sign in to comment.