Files
grafana/public/app/features/alerting/unified/components/rules/getNumberEvaluationsToStartAlerting.test.ts
Sonia Aguilar c8f87f4413 Alerting: Improving group modal with validation on evaluation interval (#57830)
* Show rules list for the group with the For duration, and add validation for keeping all rules in the same group with a valid For

* Sort rules by For duration

* Add number evaluations column in alert list

* Add Error badge in column #evaluations in case of invalid For

* Add test for getNumberEvaluationsToStartAlerting method

* Move re-usable new InfoIcon component into a separate file in unified components folder

* Add edge case for getNumberEvaluationsToStartAlerting method, and change some namings
2022-11-03 12:50:32 +01:00

18 lines
928 B
TypeScript

import { getNumberEvaluationsToStartAlerting } from './EditRuleGroupModal';
describe('getNumberEvaluationsToStartAlerting method', () => {
it('should return 0 in case of invalid data', () => {
expect(getNumberEvaluationsToStartAlerting('sd', 'ksdh')).toBe(0);
expect(getNumberEvaluationsToStartAlerting('0s', '1dfa0m')).toBe(0);
});
it('should return 1 in case of zero For and valid interval', () => {
expect(getNumberEvaluationsToStartAlerting('0s', '10m')).toBe(1);
});
it('should return correct number in case of valid data', () => {
expect(getNumberEvaluationsToStartAlerting('1m', '10m')).toBe(0);
expect(getNumberEvaluationsToStartAlerting('10m', '10m')).toBe(2);
expect(getNumberEvaluationsToStartAlerting('18m', '10m')).toBe(3);
expect(getNumberEvaluationsToStartAlerting('1h41m', '10m')).toBe(12);
expect(getNumberEvaluationsToStartAlerting('101m', '10m')).toBe(12);
});
});