cmvr-wms/ruoyi-ui-vue3/tests/unit/money-display.test.mjs
lixiaolong 6b43b0104f feat(app): 优化移动端应用配置和功能实现
- 添加生产环境服务器地址配置支持内外网切换
- 实现采购列表只看我创建的功能开关
- 更新构建脚本中的默认生产环境API地址
- 优化采购单表格单元格编辑体验改用自动补全组件
- 调整应用更新检查逻辑增强生产环境兼容性
- 修复开发服务器切换时的一些验证问题
- 增强应用启动时的服务地址配置灵活性
2026-10-30 15:02:54 +08:00

24 lines
1.1 KiB
JavaScript

import test from 'node:test'
import assert from 'node:assert/strict'
import {formatMoney} from '../../src/utils/money-display.js'
test('project amounts use grouping and fixed decimal places for numbers and decimal strings',()=>{
for (const value of [1234567.8,'1234567.80']) assert.equal(formatMoney(value),'1,234,567.80')
assert.equal(formatMoney(0),'0.00')
assert.equal(formatMoney(-12345.67),'-12,345.67')
assert.equal(formatMoney('999.999'),'1,000.00')
assert.equal(formatMoney(12),'12.00')
})
test('unit costs retain six decimal places and formatting leaves source values numeric',()=>{
const project={totalAmount:1234567.8,unitCost:'1234.123456'}
assert.equal(formatMoney(project.unitCost,6),'1,234.123456')
assert.equal(formatMoney(project.totalAmount),'1,234,567.80')
assert.deepEqual(project,{totalAmount:1234567.8,unitCost:'1234.123456'})
})
test('empty totals keep the existing zero fallback and invalid numbers never render NaN or Infinity',()=>{
for(const value of [undefined,null,'']) assert.equal(formatMoney(value),'0.00')
for(const value of ['invalid',NaN,Infinity,-Infinity]) assert.equal(formatMoney(value),'—')
})