Files
lucia-frontend/tests/unit/module/numberLabel.test.js
2026-03-06 18:57:58 +08:00

32 lines
831 B
JavaScript

// The Lucia project.
// Copyright 2026-2026 DSP, inc. All rights reserved.
// Authors:
// imacat.yang@dsp.im (imacat), 2026/03/05
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');
});
});