-
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.
jest unit tests for getKbnFieldIconType
- Loading branch information
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
x-pack/packages/ml/field_stats_flyout/get_kbn_field_icon_types.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,44 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { getKbnFieldIconType } from './get_kbn_field_icon_types'; | ||
import { ES_FIELD_TYPES } from '@kbn/field-types'; | ||
|
||
describe('getKbnFieldIconType', () => { | ||
it('should return "number" for numeric field types', () => { | ||
const numericTypes = [ | ||
ES_FIELD_TYPES.FLOAT, | ||
ES_FIELD_TYPES.HALF_FLOAT, | ||
ES_FIELD_TYPES.SCALED_FLOAT, | ||
ES_FIELD_TYPES.DOUBLE, | ||
ES_FIELD_TYPES.INTEGER, | ||
ES_FIELD_TYPES.LONG, | ||
ES_FIELD_TYPES.SHORT, | ||
ES_FIELD_TYPES.UNSIGNED_LONG, | ||
]; | ||
|
||
numericTypes.forEach((type) => { | ||
expect(getKbnFieldIconType(type)).toBe('number'); | ||
}); | ||
}); | ||
|
||
it('should return "date" for date field types', () => { | ||
const dateTypes = [ES_FIELD_TYPES.DATE, ES_FIELD_TYPES.DATE_NANOS]; | ||
|
||
dateTypes.forEach((type) => { | ||
expect(getKbnFieldIconType(type)).toBe('date'); | ||
}); | ||
}); | ||
|
||
it('should return the same type for other field types', () => { | ||
const otherTypes = ['keyword', 'text', 'boolean', 'geo_point', 'geo_shape']; | ||
|
||
otherTypes.forEach((type) => { | ||
expect(getKbnFieldIconType(type)).toBe(type); | ||
}); | ||
}); | ||
}); |