Commit 61a0d399 authored by niuyutian's avatar niuyutian

测试案例提交

parent ee5ddf34
Pipeline #314 canceled with stages
import { describe, it, expect } from 'vitest'
import numberToWords from '../../src/money/numberToWords'
describe('numberToWords', () => {
it('1 toBe 壹元整', () => {
expect(numberToWords(1)).toBe('壹元整')
})
it('1.01 toBe 壹元零壹分', () => {
expect(numberToWords(1.01)).toBe('壹元零壹分')
})
it('17916.67 toBe 壹万柒仟玖佰壹拾陆元陆角柒分', () => {
expect(numberToWords(17916.67)).toBe('壹万柒仟玖佰壹拾陆元陆角柒分')
})
it('100010000.00 toBe 壹亿零壹万元', () => {
expect(numberToWords(100010000.00)).toBe('壹亿零壹万元整')
})
it('100010000.01 toBe 壹亿零壹万元壹分', () => {
expect(numberToWords(100010000.01)).toBe('壹亿零壹万元壹分')
})
})
describe('测试整数', () => {
it('1 toBe 壹元整', () => {
expect(numberToWords(1)).toBe('壹元整')
......@@ -95,9 +77,39 @@ describe('测试整数', () => {
it('1111 toBe 壹仟壹佰壹拾壹元整', () => {
expect(numberToWords(1111)).toBe('壹仟壹佰壹拾壹元整')
})
it('100010000.00 toBe 壹亿零壹万元', () => {
expect(numberToWords(100010000.00)).toBe('壹亿零壹万元整')
})
it('1001000000 toBe 壹拾亿零壹佰万元整',()=>{
expect(numberToWords(1001000000)).toBe('壹拾亿零壹佰万元整')
})
it('500000008 toBe 伍亿零捌元整',()=>{
expect(numberToWords(500000008)).toBe('伍亿零捌元整')
})
it('500000080 toBe 伍亿零捌拾元整',()=>{
expect(numberToWords(500000080)).toBe('伍亿零捌拾元整')
})
it('500000080 toBe 伍亿零捌佰元整',()=>{
expect(numberToWords(500000800)).toBe('伍亿零捌佰元整')
})
it('500008000 toBe 伍亿零捌仟元整',()=>{
expect(numberToWords(500008000)).toBe('伍亿零捌仟元整')
})
it('500080000 toBe 伍亿零捌万元整',()=>{
expect(numberToWords(500080000)).toBe('伍亿零捌万元整')
})
it('500800000 toBe 伍亿零捌拾万元整',()=>{
expect(numberToWords(500800000)).toBe('伍亿零捌拾万元整')
})
it('508000000 toBe 伍亿零捌佰万元整',()=>{
expect(numberToWords(508000000)).toBe('伍亿零捌佰万元整')
})
it('580000000 toBe 伍亿捌仟万元整',()=>{
expect(numberToWords(580000000)).toBe('伍亿捌仟万元整')
})
})
describe('测试小数', () => {
it('0.01 toBe 壹分', () => {
expect(numberToWords(0.01)).toBe('壹分')
......@@ -153,6 +165,7 @@ describe('测试小数', () => {
it('10.00 toBe 壹拾元整', () => {
expect(numberToWords(10.00)).toBe('壹拾元整')
})
})
describe('测试极端小数', () => {
......@@ -171,4 +184,13 @@ describe('测试极端小数', () => {
it('0.456', function () {
expect(numberToWords(0.456)).toBe('肆角伍分')
})
})
describe('小数整数',()=>{
it('17916.67 toBe 壹万柒仟玖佰壹拾陆元陆角柒分', () => {
expect(numberToWords(17916.67)).toBe('壹万柒仟玖佰壹拾陆元陆角柒分')
})
it('100010000.01 toBe 壹亿零壹万元零壹分', () => {
expect(numberToWords(100010000.01)).toBe('壹亿零壹万元零壹分')
})
})
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment