mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Rename old cascader * Change name of old cascader * Add basic cascader without search * Add basic cascader without search * Flatten options to make it searchable * Add regex search and make backspace work * Add barebone search without styles * Add SearchResult list * Add search navigation * Rewrite of cascader and add some things to SelectBase * Make SelectBase controlllable * Cleanup * Add initial value functionality * Add onblur to hand caret direction * New storyboom format for ButtonCascader * Add knobs to story * Add story and docs for UnitPicker * Make UnitPicker use Cascader * Fix backspace issue and empty value * Fix backspace issue for real * Remove unused code * Fix focus issue * Change children to items and remove ButtonCascaderProps * Remove local CascaderOption * Fix failed test * Revert UnitPicker changes and change format for ButtonCascader * Fix failing tests
56 lines
1.3 KiB
TypeScript
56 lines
1.3 KiB
TypeScript
import { groupMetricsByPrefix, RECORDING_RULES_GROUP } from './PromQueryField';
|
|
|
|
describe('groupMetricsByPrefix()', () => {
|
|
it('returns an empty group for no metrics', () => {
|
|
expect(groupMetricsByPrefix([])).toEqual([]);
|
|
});
|
|
|
|
it('returns options grouped by prefix', () => {
|
|
expect(groupMetricsByPrefix(['foo_metric'])).toMatchObject([
|
|
{
|
|
value: 'foo',
|
|
items: [
|
|
{
|
|
value: 'foo_metric',
|
|
},
|
|
],
|
|
},
|
|
]);
|
|
});
|
|
|
|
it('returns options grouped by prefix with metadata', () => {
|
|
expect(groupMetricsByPrefix(['foo_metric'], { foo_metric: [{ type: 'TYPE', help: 'my help' }] })).toMatchObject([
|
|
{
|
|
value: 'foo',
|
|
items: [
|
|
{
|
|
value: 'foo_metric',
|
|
title: 'foo_metric\nTYPE\nmy help',
|
|
},
|
|
],
|
|
},
|
|
]);
|
|
});
|
|
|
|
it('returns options without prefix as toplevel option', () => {
|
|
expect(groupMetricsByPrefix(['metric'])).toMatchObject([
|
|
{
|
|
value: 'metric',
|
|
},
|
|
]);
|
|
});
|
|
|
|
it('returns recording rules grouped separately', () => {
|
|
expect(groupMetricsByPrefix([':foo_metric:'])).toMatchObject([
|
|
{
|
|
value: RECORDING_RULES_GROUP,
|
|
items: [
|
|
{
|
|
value: ':foo_metric:',
|
|
},
|
|
],
|
|
},
|
|
]);
|
|
});
|
|
});
|