grafana/public/app/plugins/datasource/testdata/metricTree.test.ts
Torkel Ödegaard 8c585a4ebf
Scene: Variables interpolation formats and multi value handling (#58591)
* Component that can cache and extract variable dependencies

* Component that can cache and extract variable dependencies

* Updates

* Refactoring

* Lots of refactoring and iterations of supporting both re-rendering and query re-execution

* Updated SceneCanvasText

* Updated name of file

* Updated

* Refactoring a bit

* Added back getName

* Added comment

* minor fix

* Minor fix

* Merge fixes

* Scene variable interpolation progress

* Merge fixes

* Added all format registeries

* Progress on multi value support

* Progress on multi value support

* Updates

* Progress on scoped vars

* Fixed circular dependency

* Updates

* Some review fixes

* Updated comment

* Added forceRender function

* Add back fail on console log

* Update public/app/features/scenes/variables/interpolation/sceneInterpolator.test.ts

* Moving functions from SceneObjectBase

* fixing tests

* Fixed e2e

Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
2022-11-16 11:36:30 +01:00

25 lines
871 B
TypeScript

import { queryMetricTree } from './metricTree';
describe('MetricTree', () => {
it('queryMetric tree return right tree nodes', () => {
const nodes = queryMetricTree('*');
expect(nodes[0].children[0].name).toBe('AA');
expect(nodes[0].children[1].name).toBe('AB');
});
it('queryMetric tree return right tree nodes', () => {
const nodes = queryMetricTree('A.AB.ABC.*');
expect(nodes[0].name).toBe('ABCA');
});
it('queryMetric tree supports glob paths', () => {
const nodes = queryMetricTree('A.{AB,AC}.*').map((i) => i.name);
expect(nodes).toEqual(expect.arrayContaining(['ABA', 'ABB', 'ABC', 'ACA', 'ACB', 'ACC']));
});
it('queryMetric tree supports wildcard matching', () => {
const nodes = queryMetricTree('A.AB.AB*').map((i) => i.name);
expect(nodes).toEqual(expect.arrayContaining(['ABA', 'ABB', 'ABC']));
});
});