Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
F
fe-utils
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sunguoshu
fe-utils
Commits
61a0d399
Commit
61a0d399
authored
Jul 17, 2023
by
niuyutian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
测试案例提交
parent
ee5ddf34
Pipeline
#314
canceled with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
19 deletions
+41
-19
numberToWords.test.ts
test/money/numberToWords.test.ts
+41
-19
No files found.
test/money/numberToWords.test.ts
View file @
61a0d399
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment