import { niceNumShow } from './niceNumShow'; const emptyVal = [{ type: 'num', text: '-' }]; describe('数字优化显示 niceNumShow 方法单元测试', () => { it('测试1 无参数', () => { expect(niceNumShow()).toStrictEqual(emptyVal); }); it('测试2 value = null', () => { expect(niceNumShow(null)).toStrictEqual(emptyVal); }); it('测试3 value = 0', () => { expect(niceNumShow(0)).toStrictEqual([{ type: 'num', text: '0' }]); }); it('测试4 value = 1234', () => { expect(niceNumShow(1234)).toStrictEqual([{ type: 'num', text: '1234' }]); }); it('测试5 value = 12.34万', () => { expect(niceNumShow('12.34万')).toStrictEqual([ { type: 'num', text: '12.34' }, { type: 'character', text: '万' }, ]); }); it('测试6 value = .23万', () => { expect(niceNumShow('.23万')).toStrictEqual([ { type: 'num', text: '.23' }, { type: 'character', text: '万' }, ]); }); it('测试7 value = $12.34亿', () => { expect(niceNumShow('$12.34亿')).toStrictEqual([ { type: 'character', text: '$' }, { type: 'num', text: '12.34' }, { type: 'character', text: '亿' }, ]); }); it('测试8 value = 12.34万 spiltPoint=true', () => { expect(niceNumShow('12.34万', true)).toStrictEqual([ { type: 'num', text: '12' }, { type: 'suffixNum', text: '.34' }, { type: 'character', text: '万' }, ]); }); it('测试9 value = .34万 spiltPoint=true', () => { expect(niceNumShow('.34万', true)).toStrictEqual([ { type: 'suffixNum', text: '.34' }, { type: 'character', text: '万' }, ]); }); it('测试10 value = $12.34亿 spiltPoint=true', () => { expect(niceNumShow('$12.34亿', true)).toStrictEqual([ { type: 'character', text: '$' }, { type: 'num', text: '12' }, { type: 'suffixNum', text: '.34' }, { type: 'character', text: '亿' }, ]); }); it('测试11 value = 23分钟34秒', () => { expect(niceNumShow('23分钟34秒')).toStrictEqual([ { type: 'num', text: '23' }, { type: 'character', text: '分钟' }, { type: 'num', text: '34' }, { type: 'character', text: '秒' }, ]); }); });