Add unit tests for utils and module pure functions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-05 19:14:13 +08:00
parent e596bcd18e
commit 83c2db7582
8 changed files with 563 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
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');
});
});