Files
alessandro 2fb102b601 refactor: remove DefeaultProps from the DatePickerIOS component (#32064)
Summary:
Closes issue  https://github.com/facebook/react-native/issues/31605.
This is part of a bigger issue that plans to remove defaultProps from class components in order to provide a smoother transition to functional components.

## Changelog

[General] [Changed] - Remove defaultProps from the DatePickerIOS Component.
[General] [Test] - Added snapshot test for the new component

Pull Request resolved: https://github.com/facebook/react-native/pull/32064

Test Plan: Compiled the rn-tester folder to check if the behavior is consistent with the previous versions.

Reviewed By: lunaleaps

Differential Revision: D30492515

Pulled By: yungsters

fbshipit-source-id: ed2c5f3211742d528ff3f8e406a53cd7ea43d7e7
2021-08-25 13:09:36 -07:00

50 lines
1.2 KiB
JavaScript

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @emails oncall+react_native
* @flow
*/
'use strict';
const React = require('react');
const DatePickerIOS = require('../DatePickerIOS');
const ReactNativeTestTools = require('../../../Utilities/ReactNativeTestTools');
describe('DatePickerIOS', () => {
it('should render as expected', () => {
ReactNativeTestTools.expectRendersMatchingSnapshot(
'DatePickerIOS',
() => (
<DatePickerIOS
date={new Date(1555883690956)}
mode="date"
onDateChange={jest.fn()}
/>
),
() => {
jest.dontMock('../DatePickerIOS');
},
);
});
it('should render DatePicker with the datetime mode if no mode is passed inside the props', () => {
ReactNativeTestTools.expectRendersMatchingSnapshot(
'DatePickerIOS',
() => (
<DatePickerIOS
date={new Date(1555883690956)}
onDateChange={jest.fn()}
/>
),
() => {
jest.dontMock('../DatePickerIOS');
},
);
});
});