query_hints.test.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { getQueryHints } from './query_hints';
  2. describe('getQueryHints', () => {
  3. describe('when called without datapoints in series', () => {
  4. it('then it should use rows instead and return correct hint', () => {
  5. const series = [
  6. {
  7. fields: [
  8. {
  9. name: 'Some Name',
  10. },
  11. ],
  12. rows: [[1], [2]],
  13. },
  14. ];
  15. const result = getQueryHints('up', series);
  16. expect(result).toEqual([
  17. {
  18. fix: { action: { query: 'up', type: 'ADD_RATE' }, label: 'Fix by adding rate().' },
  19. label: 'Time series is monotonically increasing.',
  20. type: 'APPLY_RATE',
  21. },
  22. ]);
  23. });
  24. });
  25. describe('when called without datapoints and rows in series', () => {
  26. it('then it should use an empty array and return null', () => {
  27. const series = [
  28. {
  29. fields: [
  30. {
  31. name: 'Some Name',
  32. },
  33. ],
  34. },
  35. ];
  36. const result = getQueryHints('up', series);
  37. expect(result).toEqual(null);
  38. });
  39. });
  40. });