52 lines
1.2 KiB
TypeScript
52 lines
1.2 KiB
TypeScript
// index.test.ts
|
|
import { formatMoney } from '../libs/utils/index';
|
|
|
|
describe('FormatMoneyTest', () => {
|
|
test('should format positive integer correctly', () => {
|
|
// Arrange
|
|
const input = 1234;
|
|
const expectedOutput = "1,234.00";
|
|
|
|
// Act
|
|
const result = formatMoney(input);
|
|
|
|
// Assert
|
|
expect(result).toBe(expectedOutput);
|
|
});
|
|
|
|
test('should format zero correctly', () => {
|
|
// Arrange
|
|
const input = 0;
|
|
const expectedOutput = "0.00";
|
|
|
|
// Act
|
|
const result = formatMoney(input);
|
|
|
|
// Assert
|
|
expect(result).toBe(expectedOutput);
|
|
});
|
|
|
|
test('should format large integer correctly', () => {
|
|
// Arrange
|
|
const input = 1000000;
|
|
const expectedOutput = "1,000,000.00";
|
|
|
|
// Act
|
|
const result = formatMoney(input);
|
|
|
|
// Assert
|
|
expect(result).toBe(expectedOutput);
|
|
});
|
|
|
|
test('should format negative integer correctly', () => {
|
|
// Arrange
|
|
const input = -5000;
|
|
const expectedOutput = "-5,000.00";
|
|
|
|
// Act
|
|
const result = formatMoney(input);
|
|
|
|
// Assert
|
|
expect(result).toBe(expectedOutput);
|
|
});
|
|
}); |