forked from opensearch-project/OpenSearch-Dashboards
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Discover] use roundUp when converting timestamp for PPL (opensearch-…
…project#8935) Signed-off-by: Joshua Li <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> Signed-off-by: Federico Silva <[email protected]>
- Loading branch information
1 parent
e9aec0d
commit 4e884c5
Showing
4 changed files
with
34 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fix: | ||
- Use roundUp when converting timestamp for PPL ([#8935](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8935)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import datemath from '@opensearch/datemath'; | ||
import { formatTimePickerDate } from '.'; | ||
|
||
describe('formatTimePickerDate', () => { | ||
const mockDateFormat = 'YYYY-MM-DD HH:mm:ss'; | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('should handle date range with rounding', () => { | ||
jest.spyOn(datemath, 'parse'); | ||
|
||
const result = formatTimePickerDate({ from: 'now/d', to: 'now/d' }, mockDateFormat); | ||
|
||
expect(result.fromDate).not.toEqual(result.toDate); | ||
|
||
expect(datemath.parse).toHaveBeenCalledTimes(2); | ||
expect(datemath.parse).toHaveBeenCalledWith('now/d', { roundUp: undefined }); | ||
expect(datemath.parse).toHaveBeenCalledWith('now/d', { roundUp: true }); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters