2025-06-29 20:44:33 -04:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2025 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { describe, it, expect } from 'vitest';
|
|
|
|
|
import {
|
|
|
|
|
getStatusColor,
|
|
|
|
|
TOOL_SUCCESS_RATE_HIGH,
|
|
|
|
|
TOOL_SUCCESS_RATE_MEDIUM,
|
|
|
|
|
USER_AGREEMENT_RATE_HIGH,
|
|
|
|
|
USER_AGREEMENT_RATE_MEDIUM,
|
|
|
|
|
CACHE_EFFICIENCY_HIGH,
|
|
|
|
|
CACHE_EFFICIENCY_MEDIUM,
|
|
|
|
|
} from './displayUtils.js';
|
2025-08-15 15:39:54 -07:00
|
|
|
import { theme } from '../semantic-colors.js';
|
2025-06-29 20:44:33 -04:00
|
|
|
|
|
|
|
|
describe('displayUtils', () => {
|
|
|
|
|
describe('getStatusColor', () => {
|
|
|
|
|
const thresholds = {
|
|
|
|
|
green: 80,
|
|
|
|
|
yellow: 50,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
it('should return green for values >= green threshold', () => {
|
2025-08-15 15:39:54 -07:00
|
|
|
expect(getStatusColor(90, thresholds)).toBe(theme.status.success);
|
|
|
|
|
expect(getStatusColor(80, thresholds)).toBe(theme.status.success);
|
2025-06-29 20:44:33 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should return yellow for values < green and >= yellow threshold', () => {
|
2025-08-15 15:39:54 -07:00
|
|
|
expect(getStatusColor(79, thresholds)).toBe(theme.status.warning);
|
|
|
|
|
expect(getStatusColor(50, thresholds)).toBe(theme.status.warning);
|
2025-06-29 20:44:33 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should return red for values < yellow threshold', () => {
|
2025-08-15 15:39:54 -07:00
|
|
|
expect(getStatusColor(49, thresholds)).toBe(theme.status.error);
|
|
|
|
|
expect(getStatusColor(0, thresholds)).toBe(theme.status.error);
|
2025-06-29 20:44:33 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should return defaultColor for values < yellow threshold when provided', () => {
|
|
|
|
|
expect(
|
2025-08-15 15:39:54 -07:00
|
|
|
getStatusColor(49, thresholds, { defaultColor: theme.text.primary }),
|
|
|
|
|
).toBe(theme.text.primary);
|
2025-06-29 20:44:33 -04:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('Threshold Constants', () => {
|
|
|
|
|
it('should have the correct values', () => {
|
|
|
|
|
expect(TOOL_SUCCESS_RATE_HIGH).toBe(95);
|
|
|
|
|
expect(TOOL_SUCCESS_RATE_MEDIUM).toBe(85);
|
|
|
|
|
expect(USER_AGREEMENT_RATE_HIGH).toBe(75);
|
|
|
|
|
expect(USER_AGREEMENT_RATE_MEDIUM).toBe(45);
|
|
|
|
|
expect(CACHE_EFFICIENCY_HIGH).toBe(40);
|
|
|
|
|
expect(CACHE_EFFICIENCY_MEDIUM).toBe(15);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|