Skip to content

Commit

Permalink
fe UT
Browse files Browse the repository at this point in the history
  • Loading branch information
Yongjie Zhao committed Nov 19, 2023
1 parent 223ba8b commit c77e9ec
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,34 @@ test('Open and close popover', () => {
expect(defaultProps.onClosePopover).toHaveBeenCalled();
expect(screen.queryByText('Edit time range')).not.toBeInTheDocument();
});

test('Should render shortcuts frame', () => {
render(
setup(
defaultProps,
mockStore({
common: {
conf: {
DEFAULT_TIME_FILTER: "DATETRUNC(DATETIME('today'), WEEK) : today",
TIME_FILTER_SHORTCUTS: [
['Current week', "DATETRUNC(DATETIME('today'), WEEK) : today"],
[
'Current month(MTD)',
"DATETRUNC(DATETIME('today'), MONTH) : today",
],
[
'Current year(YTD)',
"DATETRUNC(DATETIME('today'), YEAR) : today",
],
],
},
},
}),
),
);

userEvent.click(screen.getByTestId('time-range-trigger'));
expect(screen.getByText('Current week')).toBeInTheDocument();
expect(screen.getByText('Current month(MTD)')).toBeInTheDocument();
expect(screen.getByText('Current year(YTD)')).toBeInTheDocument();
});
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const guessFrame = (
if (customTimeRangeDecode(timeRange).matchedFlag) {
return 'Custom';
}
if (shortcuts.filter(s => s[1] === timeRange)) {
if (shortcuts.filter(s => s[1] === timeRange).length > 0) {
return 'Shortcuts';
}
return 'Advanced';
Expand Down

0 comments on commit c77e9ec

Please sign in to comment.