InfluxLogsQueryField.test.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import { pairsAreValid } from './InfluxLogsQueryField';
  2. describe('pairsAreValid()', () => {
  3. describe('when all pairs are fully defined', () => {
  4. it('should return true', () => {
  5. const pairs = [
  6. {
  7. key: 'a',
  8. operator: '=',
  9. value: '1',
  10. },
  11. {
  12. key: 'b',
  13. operator: '!=',
  14. value: '2',
  15. },
  16. ];
  17. expect(pairsAreValid(pairs as any)).toBe(true);
  18. });
  19. });
  20. describe('when no pairs are defined at all', () => {
  21. it('should return true', () => {
  22. expect(pairsAreValid([])).toBe(true);
  23. });
  24. });
  25. describe('when pairs are undefined', () => {
  26. it('should return true', () => {
  27. expect(pairsAreValid(undefined)).toBe(true);
  28. });
  29. });
  30. describe('when one or more pairs are only partially defined', () => {
  31. it('should return false', () => {
  32. const pairs = [
  33. {
  34. key: 'a',
  35. operator: undefined,
  36. value: '1',
  37. },
  38. {
  39. key: 'b',
  40. operator: '!=',
  41. value: '2',
  42. },
  43. ];
  44. expect(pairsAreValid(pairs as any)).toBe(false);
  45. });
  46. });
  47. });