Skip to content
This repository has been archived by the owner on May 31, 2021. It is now read-only.

Commit

Permalink
fix: the test parts set value to new Date() when there is no prop
Browse files Browse the repository at this point in the history
  • Loading branch information
oh3vci committed Sep 15, 2020
1 parent 29d4503 commit 077ca3e
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions main/__tests__/DatePicker.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import { TouchableOpacity } from 'react-native';
import { render } from '@testing-library/react-native';
import renderer from 'react-test-renderer';

const standardDate = new Date('2020-09-01');
const standardDate = new Date('2020-09-13');

describe('[DatePicker] render', () => {
it('should render without crashing', () => {
const rendered = render(<DatePicker />).asJSON();
const rendered = render(<DatePicker selectedDate={standardDate} />).asJSON();

// expect(rendered).toMatchSnapshot();
expect(rendered).toBeTruthy();
Expand All @@ -29,7 +29,7 @@ describe('[DatePicker] render', () => {
describe('[DateInput] render', () => {
it('should render without crashing', () => {
const rendered = render(
<DateInput onPressCalendar={(): void => {}} />,
<DateInput onPressCalendar={(): void => {}} selectedDate={standardDate} />,
).asJSON();

// expect(rendered).toMatchSnapshot();
Expand All @@ -39,7 +39,7 @@ describe('[DateInput] render', () => {
it('should simulate onPress', () => {
const onPressCalendar = jest.fn();
const rendered = renderer.create(
<DateInput onPressCalendar={onPressCalendar} />,
<DateInput onPressCalendar={onPressCalendar} selectedDate={standardDate} />,
{
createNodeMock: () => {
return {
Expand All @@ -63,7 +63,11 @@ describe('[DateInput] render', () => {
describe('[PickerCalendar] render', () => {
it('should render without crashing', () => {
const rendered = render(
<PickerCalendar visible={false} onSelectDate={(): void => {}} />,
<PickerCalendar
visible={false}
onSelectDate={(): void => {}}
selectedDate={standardDate}
weekdayFormat={'narrow'} />,
).asJSON();

// expect(rendered).toMatchSnapshot();
Expand All @@ -75,8 +79,9 @@ describe('[Calendar]', () => {
it('should render without crashing', () => {
const rendered = render(
<Calendar
initDate={standardDate}
renderDay={() => <CalendarDate date={standardDate} isToday={false} />}
calendarWidth={300}
renderDay={() => <CalendarDate date={standardDate}></CalendarDate>}
/>,
).asJSON();

Expand All @@ -88,7 +93,7 @@ describe('[Calendar]', () => {
describe('[CalendarDate] render', () => {
it('should render without crashing', () => {
const rendered = render(
<CalendarDate onPress={(): void => {}} date={standardDate} />,
<CalendarDate onPress={(): void => {}} date={standardDate} isToday={false} />,
).asJSON();

// expect(rendered).toMatchSnapshot();
Expand All @@ -99,7 +104,7 @@ describe('[CalendarDate] render', () => {
it('should simulate onPress', () => {
const onSelectDate = jest.fn();
const rendered = renderer.create(
<CalendarDate onPress={onSelectDate} date={standardDate} />,
<CalendarDate onPress={onSelectDate} date={standardDate} isToday={false} />,
{
createNodeMock: () => {
return {
Expand All @@ -126,8 +131,8 @@ describe('[CalendarMonth] render', () => {
<CalendarMonth
monthDate={standardDate}
calendarWidth={300}
renderDay={() => <CalendarDate date={standardDate}></CalendarDate>}
today={new Date(standardDate)}
renderDay={() => <CalendarDate date={standardDate} isToday={false} />}
today={standardDate}
/>,
).asJSON();

Expand Down

0 comments on commit 077ca3e

Please sign in to comment.