28 lines
842 B
TypeScript
28 lines
842 B
TypeScript
import {
|
|
describe,
|
|
expect,
|
|
it
|
|
} from 'vitest';
|
|
import {
|
|
exceedsHighMemoryThreshold,
|
|
formatWorkingSetGb,
|
|
HIGH_MEMORY_THRESHOLD_KB
|
|
} from './high-memory-alert.rules';
|
|
|
|
describe('high-memory-alert.rules', () => {
|
|
it('uses a 2 GiB working-set threshold', () => {
|
|
expect(HIGH_MEMORY_THRESHOLD_KB).toBe(2 * 1024 * 1024);
|
|
});
|
|
|
|
it('detects totals at or above the threshold', () => {
|
|
expect(exceedsHighMemoryThreshold(HIGH_MEMORY_THRESHOLD_KB - 1)).toBe(false);
|
|
expect(exceedsHighMemoryThreshold(HIGH_MEMORY_THRESHOLD_KB)).toBe(true);
|
|
expect(exceedsHighMemoryThreshold(HIGH_MEMORY_THRESHOLD_KB + 1024)).toBe(true);
|
|
});
|
|
|
|
it('formats working set totals in gigabytes', () => {
|
|
expect(formatWorkingSetGb(1536 * 1024)).toBe('1.50');
|
|
expect(formatWorkingSetGb(HIGH_MEMORY_THRESHOLD_KB)).toBe('2.00');
|
|
});
|
|
});
|