-
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.
[ML] Remove unused Angular filters (#51027)
- Loading branch information
1 parent
ff2a3ab
commit cdc9caa
Showing
10 changed files
with
388 additions
and
337 deletions.
There are no files selected for viewing
42 changes: 0 additions & 42 deletions
42
x-pack/legacy/plugins/ml/public/formatters/__tests__/abbreviate_whole_number.js
This file was deleted.
Oops, something went wrong.
93 changes: 0 additions & 93 deletions
93
x-pack/legacy/plugins/ml/public/formatters/__tests__/format_value.js
This file was deleted.
Oops, something went wrong.
33 changes: 0 additions & 33 deletions
33
x-pack/legacy/plugins/ml/public/formatters/__tests__/metric_change_description.js
This file was deleted.
Oops, something went wrong.
37 changes: 37 additions & 0 deletions
37
x-pack/legacy/plugins/ml/public/formatters/abbreviate_whole_number.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,37 @@ | ||
/* | ||
* 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 { abbreviateWholeNumber } from './abbreviate_whole_number'; | ||
|
||
describe('ML - abbreviateWholeNumber formatter', () => { | ||
test('returns the correct format using default max digits', () => { | ||
expect(abbreviateWholeNumber(1)).toBe(1); | ||
expect(abbreviateWholeNumber(12)).toBe(12); | ||
expect(abbreviateWholeNumber(123)).toBe(123); | ||
expect(abbreviateWholeNumber(1234)).toBe('1k'); | ||
expect(abbreviateWholeNumber(12345)).toBe('12k'); | ||
expect(abbreviateWholeNumber(123456)).toBe('123k'); | ||
expect(abbreviateWholeNumber(1234567)).toBe('1m'); | ||
expect(abbreviateWholeNumber(12345678)).toBe('12m'); | ||
expect(abbreviateWholeNumber(123456789)).toBe('123m'); | ||
expect(abbreviateWholeNumber(1234567890)).toBe('1b'); | ||
expect(abbreviateWholeNumber(5555555555555.55)).toBe('6t'); | ||
}); | ||
|
||
test('returns the correct format using custom max digits', () => { | ||
expect(abbreviateWholeNumber(1, 4)).toBe(1); | ||
expect(abbreviateWholeNumber(12, 4)).toBe(12); | ||
expect(abbreviateWholeNumber(123, 4)).toBe(123); | ||
expect(abbreviateWholeNumber(1234, 4)).toBe(1234); | ||
expect(abbreviateWholeNumber(12345, 4)).toBe('12k'); | ||
expect(abbreviateWholeNumber(123456, 6)).toBe(123456); | ||
expect(abbreviateWholeNumber(1234567, 4)).toBe('1m'); | ||
expect(abbreviateWholeNumber(12345678, 3)).toBe('12m'); | ||
expect(abbreviateWholeNumber(123456789, 9)).toBe(123456789); | ||
expect(abbreviateWholeNumber(1234567890, 3)).toBe('1b'); | ||
expect(abbreviateWholeNumber(5555555555555.55, 5)).toBe('6t'); | ||
}); | ||
}); |
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
94 changes: 94 additions & 0 deletions
94
x-pack/legacy/plugins/ml/public/formatters/format_value.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,94 @@ | ||
/* | ||
* 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 moment from 'moment-timezone'; | ||
import { AnomalyRecordDoc } from '../../common/types/anomalies'; | ||
import { formatValue } from './format_value'; | ||
|
||
describe('ML - formatValue formatter', () => { | ||
const timeOfWeekRecord: AnomalyRecordDoc = { | ||
job_id: 'gallery_time_of_week', | ||
result_type: 'record', | ||
probability: 0.012818, | ||
record_score: 53.55134, | ||
initial_record_score: 53, | ||
bucket_span: 900, | ||
detector_index: 0, | ||
is_interim: false, | ||
timestamp: 1530155700000, | ||
by_field_name: 'clientip', | ||
by_field_value: '65.55.215.39', | ||
function: 'time_of_week', | ||
function_description: 'time', | ||
}; | ||
|
||
const timeOfDayRecord: AnomalyRecordDoc = { | ||
job_id: 'gallery_time_of_day', | ||
result_type: 'record', | ||
probability: 0.012818, | ||
record_score: 97.94245, | ||
initial_record_score: 97, | ||
bucket_span: 900, | ||
detector_index: 0, | ||
is_interim: false, | ||
timestamp: 1517472900000, | ||
by_field_name: 'clientip', | ||
by_field_value: '157.56.93.83', | ||
function: 'time_of_day', | ||
function_description: 'time', | ||
}; | ||
|
||
// Set timezone to US/Eastern for time_of_day and time_of_week tests. | ||
beforeEach(() => { | ||
moment.tz.setDefault('US/Eastern'); | ||
}); | ||
|
||
afterEach(() => { | ||
moment.tz.setDefault('Browser'); | ||
}); | ||
|
||
// For time_of_day and time_of_week test values which are offsets in seconds | ||
// from UTC start of week / day are formatted correctly using the test timezone. | ||
test('correctly formats time_of_week value from numeric input', () => { | ||
expect(formatValue(359739, 'time_of_week', undefined, timeOfWeekRecord)).toBe('Wed 23:55'); | ||
}); | ||
|
||
test('correctly formats time_of_day value from numeric input', () => { | ||
expect(formatValue(73781, 'time_of_day', undefined, timeOfDayRecord)).toBe('15:29'); | ||
}); | ||
|
||
test('correctly formats number values from numeric input', () => { | ||
expect(formatValue(1483228800, 'mean')).toBe(1483228800); | ||
expect(formatValue(1234.5678, 'mean')).toBe(1234.6); | ||
expect(formatValue(0.00012345, 'mean')).toBe(0.000123); | ||
expect(formatValue(0, 'mean')).toBe(0); | ||
expect(formatValue(-0.12345, 'mean')).toBe(-0.123); | ||
expect(formatValue(-1234.5678, 'mean')).toBe(-1234.6); | ||
expect(formatValue(-100000.1, 'mean')).toBe(-100000); | ||
}); | ||
|
||
test('correctly formats time_of_week value from array input', () => { | ||
expect(formatValue([359739], 'time_of_week', undefined, timeOfWeekRecord)).toBe('Wed 23:55'); | ||
}); | ||
|
||
test('correctly formats time_of_day value from array input', () => { | ||
expect(formatValue([73781], 'time_of_day', undefined, timeOfDayRecord)).toBe('15:29'); | ||
}); | ||
|
||
test('correctly formats number values from array input', () => { | ||
expect(formatValue([1483228800], 'mean')).toBe(1483228800); | ||
expect(formatValue([1234.5678], 'mean')).toBe(1234.6); | ||
expect(formatValue([0.00012345], 'mean')).toBe(0.000123); | ||
expect(formatValue([0], 'mean')).toBe(0); | ||
expect(formatValue([-0.12345], 'mean')).toBe(-0.123); | ||
expect(formatValue([-1234.5678], 'mean')).toBe(-1234.6); | ||
expect(formatValue([-100000.1], 'mean')).toBe(-100000); | ||
}); | ||
|
||
test('correctly formats multi-valued array', () => { | ||
expect(formatValue([30.3, 26.2], 'lat_long')).toBe('[30.3,26.2]'); | ||
}); | ||
}); |
Oops, something went wrong.