Add unit tests for utils and module pure functions
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
26
tests/unit/module/numberLabel.test.js
Normal file
26
tests/unit/module/numberLabel.test.js
Normal 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');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user