39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { RatingDisplay } from './RatingDisplay';
|
|
|
|
describe('RatingDisplay', () => {
|
|
describe('happy paths', () => {
|
|
it('should format rating correctly', () => {
|
|
expect(RatingDisplay.format(0)).toBe('0');
|
|
expect(RatingDisplay.format(1234.56)).toBe('1,235');
|
|
expect(RatingDisplay.format(9999.99)).toBe('10,000');
|
|
});
|
|
|
|
it('should handle null values', () => {
|
|
expect(RatingDisplay.format(null)).toBe('—');
|
|
});
|
|
|
|
it('should handle undefined values', () => {
|
|
expect(RatingDisplay.format(undefined)).toBe('—');
|
|
});
|
|
});
|
|
|
|
describe('edge cases', () => {
|
|
it('should round down correctly', () => {
|
|
expect(RatingDisplay.format(1234.4)).toBe('1,234');
|
|
});
|
|
|
|
it('should round up correctly', () => {
|
|
expect(RatingDisplay.format(1234.6)).toBe('1,235');
|
|
});
|
|
|
|
it('should handle decimal ratings', () => {
|
|
expect(RatingDisplay.format(1234.5)).toBe('1,235');
|
|
});
|
|
|
|
it('should handle large ratings', () => {
|
|
expect(RatingDisplay.format(999999.99)).toBe('1,000,000');
|
|
});
|
|
});
|
|
});
|