Skip to content

Commit

Permalink
[fix] handle null value in date filter (apache#11655)
Browse files Browse the repository at this point in the history
  • Loading branch information
Grace Guo committed Nov 11, 2020
1 parent 8dd96ac commit 9cba83b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Expand Up @@ -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);
Expand Down
Expand Up @@ -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) };
}

Expand Down

0 comments on commit 9cba83b

Please sign in to comment.