-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bef1e78
commit 9998a69
Showing
83 changed files
with
7,234 additions
and
11,826 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,67 @@ | ||
const { default: toUnit, UNIT_LAN } = require('../dist/cjs/toUnit'); | ||
const { default: orange, Lang } = require('../dist/cjs/orange'); | ||
const { default: toUnit } = require('../dist/cjs/toUnit'); | ||
|
||
test('toUnit', () => { | ||
test('ToUnit', () => { | ||
expect(toUnit(undefined)).toBe('--'); | ||
expect(toUnit(1100)).toBe('1.10K'); | ||
expect(toUnit(1000, { lanType: UNIT_LAN.ZH_CN, precision: 3 })).toBe("1000"); | ||
expect(toUnit(12200, { lanType: UNIT_LAN.ZH_CN, precision: 3 })).toBe('1.220万'); | ||
expect(toUnit(122000, { lanType: UNIT_LAN.ZH_CN })).toBe('12.20万'); | ||
expect(toUnit(1220000, { lanType: UNIT_LAN.ZH_CN })).toBe('122万'); | ||
expect(toUnit(12200000, { lanType: UNIT_LAN.ZH_CN })).toBe('1220万'); | ||
expect(toUnit(122000000, { lanType: UNIT_LAN.ZH_CN })).toBe('1.22亿'); | ||
expect(toUnit(1220000000, { lanType: UNIT_LAN.ZH_CN })).toBe('12.20亿'); | ||
expect(toUnit(12200000000, { lanType: UNIT_LAN.ZH_CN })).toBe('122亿'); | ||
expect(toUnit(122000000000, { lanType: UNIT_LAN.ZH_CN })).toBe('1220亿'); | ||
expect(toUnit(1220000000000, { lanType: UNIT_LAN.ZH_CN })).toBe('1.22万亿'); | ||
expect(toUnit(12200000000000, { lanType: UNIT_LAN.ZH_CN })).toBe('12.20万亿'); | ||
expect(toUnit(122000000000000, { lanType: UNIT_LAN.ZH_CN })).toBe('122万亿'); | ||
expect(toUnit(1220000000000000, { lanType: UNIT_LAN.ZH_CN })).toBe('1220万亿'); | ||
|
||
expect(toUnit(122000)).toBe('122K'); | ||
expect(toUnit(122000, { lanType: Lang.ZH_CN })).toBe('12.20万'); | ||
expect(toUnit(122000, { lanType: Lang.ZH_TW })).toBe('12.20萬'); | ||
}); | ||
|
||
test('ToUnit By EN_US', () => { | ||
orange.precision = 2; | ||
expect(toUnit(1000)).toBe("1K"); | ||
expect(toUnit(1000, { precision: 3, ignoreIntegerPrecision: false })).toBe("1.000K"); | ||
expect(toUnit(12200)).toBe('12.20K'); | ||
|
||
orange.precision = 3; | ||
expect(toUnit(122000)).toBe('122K'); | ||
expect(toUnit(1220000)).toBe('1.220M'); | ||
expect(toUnit(12200000)).toBe('12.200M'); | ||
expect(toUnit(122000000)).toBe('122M'); | ||
expect(toUnit(1220000000)).toBe('1.220B'); | ||
expect(toUnit(12200000000)).toBe('12.200B'); | ||
expect(toUnit(122000000000)).toBe('122B'); | ||
expect(toUnit(1220000000000)).toBe('1.220T'); | ||
expect(toUnit(12200000000000)).toBe('12.200T'); | ||
expect(toUnit(122000000000000)).toBe('122T'); | ||
expect(toUnit(1220000000000000)).toBe('1220T'); | ||
}); | ||
|
||
test('toUnit By ZH_CN', () => { | ||
orange.precision = 2; | ||
orange.lang = Lang.ZH_CN; | ||
|
||
expect(toUnit(1000)).toBe("1000"); | ||
expect(toUnit(122000)).toBe('12.20万'); | ||
expect(toUnit(1220000)).toBe('122万'); | ||
expect(toUnit(12200000)).toBe('1220万'); | ||
expect(toUnit(122000000)).toBe('1.22亿'); | ||
expect(toUnit(1220000000)).toBe('12.20亿'); | ||
expect(toUnit(12200000000)).toBe('122亿'); | ||
expect(toUnit(122000000000)).toBe('1220亿'); | ||
expect(toUnit(1220000000000)).toBe('1.22万亿'); | ||
expect(toUnit(12200000000000)).toBe('12.20万亿'); | ||
expect(toUnit(122000000000000)).toBe('122万亿'); | ||
expect(toUnit(1220000000000000)).toBe('1220万亿'); | ||
}) | ||
|
||
test('toUnit By ZH_TW', () => { | ||
orange.precision = 2; | ||
orange.lang = Lang.ZH_TW; | ||
|
||
expect(toUnit(1000)).toBe("1000"); | ||
expect(toUnit(122000)).toBe('12.20萬'); | ||
expect(toUnit(1220000)).toBe('122萬'); | ||
expect(toUnit(12200000)).toBe('1220萬'); | ||
expect(toUnit(122000000)).toBe('1.22億'); | ||
expect(toUnit(1220000000)).toBe('12.20億'); | ||
expect(toUnit(12200000000)).toBe('122億'); | ||
expect(toUnit(122000000000)).toBe('1220億'); | ||
expect(toUnit(1220000000000)).toBe('1.22萬億'); | ||
expect(toUnit(12200000000000)).toBe('12.20萬億'); | ||
expect(toUnit(122000000000000)).toBe('122萬億'); | ||
expect(toUnit(1220000000000000)).toBe('1220萬億'); | ||
}) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.