grafana/public/app/plugins/datasource/testdata/metricTree.test.ts
Hugo Häggmark cb0e80e7b9 TemplateVariables: Introduces $__searchFilter to Query Variables (#19858)
* WIP: Initial hardcoded version

* Feature: Introduces SearchFiltering to Graphite

* Feature: Adds searchFiltering to MySql

* Tests: Adds tests to Graphite and MySql

* Feature: Adds $__searchFilter to TestData

* Refactor: Adds searchFilter to Postgres and extracts function

* Tests: Adds tests to variable

* Refactor: Adds debounce and lodash import optimization

* Docs: Adds documentation

* Refactor: Removes unused function and fixes typo

* Docs: Updates docs

* Fixed issue with UI not updating when no  was used due to async func and no .apply in the non lazy path
2019-10-18 11:40:08 +02:00

25 lines
819 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(['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(['ABA', 'ABB', 'ABC']);
});
});