forked from elastic/kibana
-
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.
[ML] Injectables refactor (elastic#50512) (elastic#50910)
* [ML] Injectables refactor * removing unrelated files * additional typescript conversion * more typescript conversion * adding some return types * fixing eui errors * typescripting license checks * updated based on review * fixing merge conflict error * converting tests to jest * fixing types
- Loading branch information
1 parent
14579af
commit dd5f7db
Showing
63 changed files
with
571 additions
and
656 deletions.
There are no files selected for viewing
70 changes: 0 additions & 70 deletions
70
x-pack/legacy/plugins/ml/common/util/__tests__/parse_interval.js
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
34 changes: 34 additions & 0 deletions
34
x-pack/legacy/plugins/ml/common/util/parse_interval.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,34 @@ | ||
/* | ||
* 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 { parseInterval } from './parse_interval'; | ||
|
||
describe('ML parse interval util', () => { | ||
test('correctly parses an interval containing unit and value', () => { | ||
expect(parseInterval('1d')!.as('d')).toBe(1); | ||
expect(parseInterval('2y')!.as('y')).toBe(2); | ||
expect(parseInterval('5M')!.as('M')).toBe(5); | ||
expect(parseInterval('5m')!.as('m')).toBe(5); | ||
expect(parseInterval('250ms')!.as('ms')).toBe(250); | ||
expect(parseInterval('100s')!.as('s')).toBe(100); | ||
expect(parseInterval('23d')!.as('d')).toBe(23); | ||
expect(parseInterval('52w')!.as('w')).toBe(52); | ||
expect(parseInterval('0s')!.as('s')).toBe(0); | ||
expect(parseInterval('0s')!.as('h')).toBe(0); | ||
}); | ||
|
||
test('correctly handles zero value intervals', () => { | ||
expect(parseInterval('0h')!.as('h')).toBe(0); | ||
expect(parseInterval('0d')).toBe(null); | ||
}); | ||
|
||
test('returns null for an invalid interval', () => { | ||
expect(parseInterval('')).toBe(null); | ||
expect(parseInterval('234asdf')).toBe(null); | ||
expect(parseInterval('m')).toBe(null); | ||
expect(parseInterval('1.5h')).toBe(null); | ||
}); | ||
}); |
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 was deleted.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.