-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[XY] Fixes the scale type on a terms aggregation on a number field (#…
…115729) (#115894) Co-authored-by: Stratoula Kalafateli <[email protected]>
- Loading branch information
1 parent
9e7cc15
commit 6ed83ae
Showing
2 changed files
with
83 additions
and
2 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,78 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { getScale } from './get_axis'; | ||
import type { Scale } from '../types'; | ||
|
||
describe('getScale', () => { | ||
const axisScale = { | ||
type: 'linear', | ||
mode: 'normal', | ||
scaleType: 'linear', | ||
} as Scale; | ||
|
||
it('returns linear type for a number', () => { | ||
const format = { id: 'number' }; | ||
const scale = getScale(axisScale, {}, format, true); | ||
expect(scale.type).toBe('linear'); | ||
}); | ||
|
||
it('returns ordinal type for a terms aggregation on a number field', () => { | ||
const format = { | ||
id: 'terms', | ||
params: { | ||
id: 'number', | ||
otherBucketLabel: 'Other', | ||
missingBucketLabel: 'Missing', | ||
}, | ||
}; | ||
const scale = getScale(axisScale, {}, format, true); | ||
expect(scale.type).toBe('ordinal'); | ||
}); | ||
|
||
it('returns ordinal type for a terms aggregation on a string field', () => { | ||
const format = { | ||
id: 'terms', | ||
params: { | ||
id: 'string', | ||
otherBucketLabel: 'Other', | ||
missingBucketLabel: 'Missing', | ||
}, | ||
}; | ||
const scale = getScale(axisScale, {}, format, true); | ||
expect(scale.type).toBe('ordinal'); | ||
}); | ||
|
||
it('returns ordinal type for a range aggregation on a number field', () => { | ||
const format = { | ||
id: 'range', | ||
params: { | ||
id: 'number', | ||
}, | ||
}; | ||
const scale = getScale(axisScale, {}, format, true); | ||
expect(scale.type).toBe('ordinal'); | ||
}); | ||
|
||
it('returns time type for a date histogram aggregation', () => { | ||
const format = { | ||
id: 'date', | ||
params: { | ||
pattern: 'HH:mm', | ||
}, | ||
}; | ||
const scale = getScale(axisScale, { date: true }, format, true); | ||
expect(scale.type).toBe('time'); | ||
}); | ||
|
||
it('returns linear type for an histogram aggregation', () => { | ||
const format = { id: 'number' }; | ||
const scale = getScale(axisScale, { interval: 1 }, format, true); | ||
expect(scale.type).toBe('linear'); | ||
}); | ||
}); |
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