onDemandMetricAlert.spec.tsx 1.2 KB

123456789101112131415161718192021222324252627
  1. import {Dataset} from 'sentry/views/alerts/rules/metric/types';
  2. import {isOnDemandMetricAlert} from 'sentry/views/alerts/rules/metric/utils/onDemandMetricAlert';
  3. describe('isOnDemandMetricAlert', () => {
  4. it('should return true for an alert that contains non standard fields', () => {
  5. const dataset = Dataset.GENERIC_METRICS;
  6. expect(isOnDemandMetricAlert(dataset, 'transaction.duration:>1')).toBeTruthy();
  7. expect(isOnDemandMetricAlert(dataset, 'device.name:foo')).toBeTruthy();
  8. expect(isOnDemandMetricAlert(dataset, 'geo.region:>US')).toBeTruthy();
  9. });
  10. it('should return false for an alert that has only standard fields', () => {
  11. const dataset = Dataset.GENERIC_METRICS;
  12. expect(isOnDemandMetricAlert(dataset, 'release:1.0')).toBeFalsy();
  13. expect(isOnDemandMetricAlert(dataset, 'browser.name:chrome')).toBeFalsy();
  14. });
  15. it('should return false if dataset is not generic_metrics', () => {
  16. const dataset = Dataset.TRANSACTIONS;
  17. expect(isOnDemandMetricAlert(dataset, 'transaction.duration:>1')).toBeFalsy();
  18. expect(isOnDemandMetricAlert(dataset, 'device.name:foo')).toBeFalsy();
  19. expect(isOnDemandMetricAlert(dataset, 'geo.region:>US')).toBeFalsy();
  20. });
  21. });