mirror of
https://github.com/apache/superset.git
synced 2026-04-07 18:35:15 +00:00
[fix] handle null value in date filter (#11655)
This commit is contained in:
@@ -81,6 +81,19 @@ describe('DateFilterControl', () => {
|
||||
expect(close).toBeCalled();
|
||||
});
|
||||
|
||||
it('should handle null value', () => {
|
||||
const open = jest.fn();
|
||||
const close = jest.fn();
|
||||
const props = {
|
||||
...defaultProps,
|
||||
value: null,
|
||||
onOpenDateFilterControl: open,
|
||||
onCloseDateFilterControl: close,
|
||||
};
|
||||
|
||||
expect(mount(<DateFilterControl {...props} />)).toExist();
|
||||
});
|
||||
|
||||
it('renders two tabs in popover', () => {
|
||||
const popoverContent = wrapper.find(Popover).first().props().content;
|
||||
const popoverContentWrapper = mount(popoverContent);
|
||||
|
||||
@@ -236,11 +236,11 @@ class DateFilterControl extends React.Component {
|
||||
};
|
||||
|
||||
const { value } = props;
|
||||
if (value.indexOf(SEPARATOR) >= 0) {
|
||||
if (value && value.indexOf(SEPARATOR) >= 0) {
|
||||
this.state = { ...this.state, ...getStateFromSeparator(value) };
|
||||
} else if (COMMON_TIME_FRAMES.indexOf(value) >= 0) {
|
||||
this.state = { ...this.state, ...getStateFromCommonTimeFrame(value) };
|
||||
} else {
|
||||
} else if (value) {
|
||||
this.state = { ...this.state, ...getStateFromCustomRange(value) };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user