Commit f008d11d authored by sunguoshu's avatar sunguoshu

增加特殊情况

parent 10ed5d6b
......@@ -3,7 +3,6 @@ import numberToWords from '../../src/money/numberToWords'
import numberToWords2 from '../../src/money/numberToWords2'
import numberToWords3 from '../../src/money/numberToWords3'
describe('测试整数', () => {
it('0 toBe 零元整', () => {
expect(numberToWords(0)).toBe('零元整')
......@@ -260,6 +259,24 @@ describe('小数整数', () => {
it('839109939.677061 toBe 捌亿叁仟玖佰壹拾万零玖仟玖佰叁拾玖元陆角柒分', () => {
expect(numberToWords(839109939.677061)).toBe('捌亿叁仟玖佰壹拾万零玖仟玖佰叁拾玖元陆角柒分')
})
it('839109939.677061 toBe 捌亿叁仟玖佰壹拾万零玖仟玖佰叁拾玖元陆角柒分', () => {
expect(numberToWords2(839109939.677061)).toBe('捌亿叁仟玖佰壹拾万零玖仟玖佰叁拾玖元陆角柒分')
})
it('839109939.677061 toBe 捌亿叁仟玖佰壹拾万零玖仟玖佰叁拾玖元陆角柒分', () => {
expect(numberToWords3(839109939.677061)).toBe('捌亿叁仟玖佰壹拾万零玖仟玖佰叁拾玖元陆角柒分')
})
})
describe('测试特殊情况', () => {
it('-1 toBe error', () => {
expect(numberToWords(-1)).toBe('负壹元整')
})
it('-1 toBe error', () => {
expect(() => numberToWords2(-1)).toThrowError('数字不能为负数')
})
it('-1 toBe error', () => {
expect(numberToWords3(-1)).toBe('负壹元整')
})
})
describe('随机数测试', () => {
......@@ -268,7 +285,6 @@ describe('随机数测试', () => {
const random = Math.random() * 1000000000000
const result = numberToWords3(random)
const result2 = numberToWords2(random)
console.log(random, result, result2)
expect(result).toBe(result2)
}
})
......
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