-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Uptime] [Blocker] Move absolute date parsing to URL params hook (#46066
) (#46093) * Move absolute date parsing to URL params hook. * Clean up naming. * Update code to avoid putting dynamically-computed values in URL. * Add test for new helper function.
- Loading branch information
1 parent
f497b61
commit 34306fc
Showing
17 changed files
with
143 additions
and
60 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
4 changes: 2 additions & 2 deletions
4
.../uptime/public/components/functional/__tests__/__snapshots__/monitor_charts.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
2 changes: 1 addition & 1 deletion
2
...k/legacy/plugins/uptime/public/hooks/__tests__/__snapshots__/use_url_params.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
14 changes: 12 additions & 2 deletions
14
...ublic/lib/helper/url_params/__tests__/__snapshots__/get_supported_url_params.test.ts.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
30 changes: 30 additions & 0 deletions
30
.../legacy/plugins/uptime/public/lib/helper/url_params/__tests__/parse_absolute_date.test.ts
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,30 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import DateMath from '@elastic/datemath'; | ||
import moment from 'moment'; | ||
import { parseAbsoluteDate } from '../parse_absolute_date'; | ||
|
||
describe('parseAbsoluteDate', () => { | ||
let dateMathSpy: any; | ||
const MOCK_VALUE = 132435465789; | ||
|
||
beforeEach(() => { | ||
dateMathSpy = jest.spyOn(DateMath, 'parse'); | ||
dateMathSpy.mockReturnValue(moment(MOCK_VALUE)); | ||
}); | ||
|
||
it('returns the parsed value for a valid date string', () => { | ||
const result = parseAbsoluteDate('now-15m', 12345); | ||
expect(result).toBe(MOCK_VALUE); | ||
}); | ||
|
||
it('returns the default value if the parser provides `undefined`', () => { | ||
dateMathSpy.mockReturnValue(undefined); | ||
const result = parseAbsoluteDate('this is not a valid datae', 12345); | ||
expect(result).toBe(12345); | ||
}); | ||
}); |
Oops, something went wrong.