view data tests
This commit is contained in:
38
apps/website/lib/display-objects/RatingDisplay.test.ts
Normal file
38
apps/website/lib/display-objects/RatingDisplay.test.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
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');
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user