123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- import {determineSeriesConfidence} from 'sentry/views/alerts/rules/metric/utils/determineSeriesConfidence';
- describe('determineSeriesConfidence', () => {
- it('equal null if no data', () => {
- const confidence = determineSeriesConfidence({
- data: [],
- });
- expect(confidence).toBeNull();
- });
- it('equal null if no confidence found', () => {
- const confidence = determineSeriesConfidence({
- data: [
- [100, [{count: 100}]],
- [200, [{count: 200}]],
- ],
- });
- expect(confidence).toBeNull();
- });
- it('equal null if confidence is empty', () => {
- const confidence = determineSeriesConfidence({
- data: [
- [100, [{count: 100}]],
- [200, [{count: 200}]],
- ],
- confidence: [],
- });
- expect(confidence).toBeNull();
- });
- it('equal null if all confidence null', () => {
- const confidence = determineSeriesConfidence({
- data: [
- [100, [{count: 100}]],
- [200, [{count: 200}]],
- ],
- confidence: [
- [100, [{count: null}]],
- [200, [{count: null}]],
- ],
- });
- expect(confidence).toBeNull();
- });
- it('equal high if all confidence high', () => {
- const confidence = determineSeriesConfidence({
- data: [
- [100, [{count: 100}]],
- [200, [{count: 200}]],
- ],
- confidence: [
- [100, [{count: 'high'}]],
- [200, [{count: 'high'}]],
- ],
- });
- expect(confidence).toBe('high');
- });
- it('equal high if all confidence high or null', () => {
- const confidence = determineSeriesConfidence({
- data: [
- [100, [{count: 100}]],
- [200, [{count: 200}]],
- ],
- confidence: [
- [100, [{count: 'high'}]],
- [200, [{count: null}]],
- ],
- });
- expect(confidence).toBe('high');
- });
- it('equal high if <25% is low', () => {
- const confidence = determineSeriesConfidence({
- data: [
- [100, [{count: 100}]],
- [200, [{count: 200}]],
- [300, [{count: 300}]],
- [400, [{count: 400}]],
- [500, [{count: 500}]],
- [600, [{count: 600}]],
- [700, [{count: 700}]],
- ],
- confidence: [
- [100, [{count: 'high'}]],
- [200, [{count: 'high'}]],
- [300, [{count: 'high'}]],
- [400, [{count: 'high'}]],
- [500, [{count: 'low'}]],
- [600, [{count: 'high'}]],
- [700, [{count: null}]],
- ],
- });
- expect(confidence).toBe('high');
- });
- it('equal low if >25% is low', () => {
- const confidence = determineSeriesConfidence({
- data: [
- [100, [{count: 100}]],
- [200, [{count: 200}]],
- [300, [{count: 300}]],
- [400, [{count: 400}]],
- [500, [{count: 500}]],
- ],
- confidence: [
- [100, [{count: 'high'}]],
- [200, [{count: null}]],
- [300, [{count: null}]],
- [400, [{count: 'low'}]],
- [500, [{count: 'low'}]],
- ],
- });
- expect(confidence).toBe('low');
- });
- it('equal low if all low', () => {
- const confidence = determineSeriesConfidence({
- data: [
- [100, [{count: 100}]],
- [200, [{count: 200}]],
- [300, [{count: 300}]],
- [400, [{count: 400}]],
- [500, [{count: 500}]],
- ],
- confidence: [
- [100, [{count: 'low'}]],
- [200, [{count: 'low'}]],
- [300, [{count: 'low'}]],
- [400, [{count: 'low'}]],
- [500, [{count: 'low'}]],
- ],
- });
- expect(confidence).toBe('low');
- });
- it('equals low if any in bucket is low', () => {
- const confidence = determineSeriesConfidence({
- data: [[200, [{count: 100}]]],
- confidence: [
- [100, [{count: 'high'}, {count: 'low'}, {count: null}]],
- [200, [{count: null}, {count: 'low'}, {count: 'high'}]],
- ],
- });
- expect(confidence).toBe('low');
- });
- it('equals high if no lows in bucket', () => {
- const confidence = determineSeriesConfidence({
- data: [[200, [{count: 100}]]],
- confidence: [
- [100, [{count: 'high'}, {count: 'high'}, {count: null}]],
- [200, [{count: null}, {count: null}, {count: 'high'}]],
- ],
- });
- expect(confidence).toBe('high');
- });
- });
|