123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- import {
- getColdAppStartPerformance,
- getWarmAppStartPerformance,
- type MetricValue,
- PerformanceScore,
- } from 'sentry/views/insights/mobile/screens/utils';
- import {VitalState} from 'sentry/views/performance/vitalDetail/utils';
- jest.mock('sentry/utils/usePageFilters');
- jest.mock('sentry/utils/useLocation');
- describe('Utils', function () {
- describe('Cold App Start', function () {
- it('renders bad', function () {
- const value: MetricValue = {unit: 'millisecond', value: 10000, type: 'duration'};
- const performance = getColdAppStartPerformance(value);
- expect(performance.score).toBe(PerformanceScore.BAD);
- expect(performance.description).toBe(VitalState.POOR);
- });
- it('renders meh', function () {
- const value: MetricValue = {unit: 'millisecond', value: 4000, type: 'duration'};
- const performance = getColdAppStartPerformance(value);
- expect(performance.score).toBe(PerformanceScore.NEEDS_IMPROVEMENT);
- expect(performance.description).toBe(VitalState.MEH);
- });
- it('renders good', function () {
- const value: MetricValue = {unit: 'millisecond', value: 1000, type: 'duration'};
- const performance = getColdAppStartPerformance(value);
- expect(performance.score).toBe(PerformanceScore.GOOD);
- expect(performance.description).toBe(VitalState.GOOD);
- });
- it('renders unknown', function () {
- const value: MetricValue = {unit: 'millisecond', value: 0, type: 'duration'};
- const performance = getColdAppStartPerformance(value);
- expect(performance.score).toBe(PerformanceScore.NONE);
- expect(performance.description).toBe('');
- });
- });
- describe('Warm App Start', function () {
- it('renders bad', function () {
- const value: MetricValue = {unit: 'millisecond', value: 3000, type: 'duration'};
- const performance = getWarmAppStartPerformance(value);
- expect(performance.score).toBe(PerformanceScore.BAD);
- expect(performance.description).toBe(VitalState.POOR);
- });
- it('renders meh', function () {
- const value: MetricValue = {unit: 'millisecond', value: 1500, type: 'duration'};
- const performance = getWarmAppStartPerformance(value);
- expect(performance.score).toBe(PerformanceScore.NEEDS_IMPROVEMENT);
- expect(performance.description).toBe(VitalState.MEH);
- });
- it('renders good', function () {
- const value: MetricValue = {unit: 'millisecond', value: 500, type: 'duration'};
- const performance = getWarmAppStartPerformance(value);
- expect(performance.score).toBe(PerformanceScore.GOOD);
- expect(performance.description).toBe(VitalState.GOOD);
- });
- it('renders unknown', function () {
- const value: MetricValue = {unit: 'millisecond', value: 0, type: 'duration'};
- const performance = getWarmAppStartPerformance(value);
- expect(performance.score).toBe(PerformanceScore.NONE);
- expect(performance.description).toBe('');
- });
- });
- });
|