Files
lucia-frontend/tests/unit/module/numberLabel.test.js
2026-03-05 19:14:13 +08:00

27 lines
696 B
JavaScript

import { describe, it, expect } from 'vitest';
import numberLabel from '@/module/numberLabel.js';
describe('numberLabel', () => {
it('formats small numbers without commas', () => {
expect(numberLabel(1)).toBe('1');
expect(numberLabel(999)).toBe('999');
});
it('formats thousands with commas', () => {
expect(numberLabel(1000)).toBe('1,000');
expect(numberLabel(12345)).toBe('12,345');
});
it('formats millions with commas', () => {
expect(numberLabel(1234567)).toBe('1,234,567');
});
it('preserves decimal places', () => {
expect(numberLabel(1234.56)).toBe('1,234.56');
});
it('handles zero', () => {
expect(numberLabel(0)).toBe('0');
});
});