PromQueryField.test.tsx 967 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { groupMetricsByPrefix, RECORDING_RULES_GROUP } from './PromQueryField';
  2. describe('groupMetricsByPrefix()', () => {
  3. it('returns an empty group for no metrics', () => {
  4. expect(groupMetricsByPrefix([])).toEqual([]);
  5. });
  6. it('returns options grouped by prefix', () => {
  7. expect(groupMetricsByPrefix(['foo_metric'])).toMatchObject([
  8. {
  9. value: 'foo',
  10. children: [
  11. {
  12. value: 'foo_metric',
  13. },
  14. ],
  15. },
  16. ]);
  17. });
  18. it('returns options without prefix as toplevel option', () => {
  19. expect(groupMetricsByPrefix(['metric'])).toMatchObject([
  20. {
  21. value: 'metric',
  22. },
  23. ]);
  24. });
  25. it('returns recording rules grouped separately', () => {
  26. expect(groupMetricsByPrefix([':foo_metric:'])).toMatchObject([
  27. {
  28. value: RECORDING_RULES_GROUP,
  29. children: [
  30. {
  31. value: ':foo_metric:',
  32. },
  33. ],
  34. },
  35. ]);
  36. });
  37. });