Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
9 changes: 3 additions & 6 deletions Libraries/Components/DatePicker/DatePickerIOS.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,6 @@ type Props = $ReadOnly<{|
* source of truth.
*/
class DatePickerIOS extends React.Component<Props> {
static DefaultProps: {|mode: $TEMPORARY$string<'datetime'>|} = {
mode: 'datetime',
};

_picker: ?React.ElementRef<typeof RCTDatePickerNativeComponent> = null;

componentDidUpdate() {
Expand All @@ -142,6 +138,7 @@ class DatePickerIOS extends React.Component<Props> {

render(): React.Node {
const props = this.props;
const mode = props.mode ?? 'datetime';
invariant(
props.date || props.initialDate,
'A selected date or initial date should be specified.',
Expand All @@ -153,7 +150,7 @@ class DatePickerIOS extends React.Component<Props> {
ref={picker => {
this._picker = picker;
}}
style={getHeight(props.pickerStyle, props.mode)}
style={getHeight(props.pickerStyle, mode)}
date={
props.date
? props.date.getTime()
Expand All @@ -172,7 +169,7 @@ class DatePickerIOS extends React.Component<Props> {
minimumDate={
props.minimumDate ? props.minimumDate.getTime() : undefined
}
mode={props.mode}
mode={mode}
minuteInterval={props.minuteInterval}
timeZoneOffsetInMinutes={props.timeZoneOffsetInMinutes}
onChange={this._onChange}
Expand Down
14 changes: 14 additions & 0 deletions Libraries/Components/DatePicker/__tests__/DatePickerIOS-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,18 @@ describe('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');
},
);
});
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,53 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`DatePickerIOS should render DatePicker with the datetime mode if no mode is passed inside the props: should deep render when mocked (please verify output manually) 1`] = `
<View>
<RCTDatePicker
date={1555883690956}
mode="datetime"
onChange={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"height": 216,
}
}
/>
</View>
`;

exports[`DatePickerIOS should render DatePicker with the datetime mode if no mode is passed inside the props: should deep render when not mocked (please verify output manually) 1`] = `
<View>
<RCTDatePicker
date={1555883690956}
mode="datetime"
onChange={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"height": 216,
}
}
/>
</View>
`;

exports[`DatePickerIOS should render DatePicker with the datetime mode if no mode is passed inside the props: should shallow render as <DatePickerIOS /> when mocked 1`] = `
<DatePickerIOS
date={2019-04-21T21:54:50.956Z}
onDateChange={[MockFunction]}
/>
`;

exports[`DatePickerIOS should render DatePicker with the datetime mode if no mode is passed inside the props: should shallow render as <DatePickerIOS /> when not mocked 1`] = `
<DatePickerIOS
date={2019-04-21T21:54:50.956Z}
onDateChange={[MockFunction]}
/>
`;

exports[`DatePickerIOS should render as expected: should deep render when mocked (please verify output manually) 1`] = `
<View>
<RCTDatePicker
Expand Down