metricTree.test.ts 823 B

123456789101112131415161718192021222324
  1. import { queryMetricTree } from './metricTree';
  2. describe('MetricTree', () => {
  3. it('queryMetric tree return right tree nodes', () => {
  4. const nodes = queryMetricTree('*');
  5. expect(nodes[0].children[0].name).toBe('AA');
  6. expect(nodes[0].children[1].name).toBe('AB');
  7. });
  8. it('queryMetric tree return right tree nodes', () => {
  9. const nodes = queryMetricTree('A.AB.ABC.*');
  10. expect(nodes[0].name).toBe('ABCA');
  11. });
  12. it('queryMetric tree supports glob paths', () => {
  13. const nodes = queryMetricTree('A.{AB,AC}.*').map((i) => i.name);
  14. expect(nodes).toEqual(['ABA', 'ABB', 'ABC', 'ACA', 'ACB', 'ACC']);
  15. });
  16. it('queryMetric tree supports wildcard matching', () => {
  17. const nodes = queryMetricTree('A.AB.AB*').map((i) => i.name);
  18. expect(nodes).toEqual(['ABA', 'ABB', 'ABC']);
  19. });
  20. });