23 lines
857 B
TypeScript
23 lines
857 B
TypeScript
import { describe, expect, test } from 'bun:test';
|
|
import { chooseFrameRate, frameIntervalMs } from './frame-pacing';
|
|
|
|
describe('per-display frame pacing', () => {
|
|
test('follows the display refresh when no FPS override is configured', () => {
|
|
expect(chooseFrameRate(0, 144)).toBe(144);
|
|
expect(chooseFrameRate(undefined, 360)).toBe(360);
|
|
});
|
|
|
|
test('caps a per-window override at its display refresh', () => {
|
|
expect(chooseFrameRate(240, 144)).toBe(144);
|
|
expect(chooseFrameRate(120, 360)).toBe(120);
|
|
});
|
|
|
|
test('does not impose a global FPS ceiling above high-refresh displays', () => {
|
|
expect(chooseFrameRate(1000, 360)).toBe(360);
|
|
});
|
|
|
|
test('falls back to 60 Hz when display information is unavailable', () => {
|
|
expect(chooseFrameRate(0, 0)).toBe(60);
|
|
expect(frameIntervalMs(144)).toBeCloseTo(1000 / 144);
|
|
});
|
|
});
|