Files
gridpilot.gg/apps/website/lib/formatters/FinishFormatter.test.ts
Marc Mintel 3db2209d2a
Some checks failed
CI / lint-typecheck (push) Failing after 4m52s
CI / tests (push) Has been skipped
CI / contract-tests (push) Has been skipped
CI / e2e-tests (push) Has been skipped
CI / comment-pr (push) Has been skipped
CI / commit-types (push) Has been skipped
formatter tests
2026-01-25 11:17:47 +01:00

61 lines
1.7 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { FinishFormatter } from './FinishFormatter';
describe('FinishFormatter', () => {
describe('format', () => {
it('should format position as "P1"', () => {
expect(FinishFormatter.format(1)).toBe('P1');
});
it('should format position as "P2"', () => {
expect(FinishFormatter.format(2)).toBe('P2');
});
it('should format position as "P10"', () => {
expect(FinishFormatter.format(10)).toBe('P10');
});
it('should handle null value', () => {
expect(FinishFormatter.format(null)).toBe('—');
});
it('should handle undefined value', () => {
expect(FinishFormatter.format(undefined)).toBe('—');
});
it('should handle decimal positions', () => {
expect(FinishFormatter.format(5.5)).toBe('P5');
});
it('should handle large positions', () => {
expect(FinishFormatter.format(100)).toBe('P100');
});
});
describe('formatAverage', () => {
it('should format average as "P5.4"', () => {
expect(FinishFormatter.formatAverage(5.4)).toBe('P5.4');
});
it('should format average as "P10.0"', () => {
expect(FinishFormatter.formatAverage(10.0)).toBe('P10.0');
});
it('should handle null value', () => {
expect(FinishFormatter.formatAverage(null)).toBe('—');
});
it('should handle undefined value', () => {
expect(FinishFormatter.formatAverage(undefined)).toBe('—');
});
it('should handle decimal averages', () => {
expect(FinishFormatter.formatAverage(5.123)).toBe('P5.1');
});
it('should handle large averages', () => {
expect(FinishFormatter.formatAverage(100.5)).toBe('P100.5');
});
});
});