Skip to content

Commit

Permalink
release: v4.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
moonlitusun committed Apr 12, 2024
1 parent bef1e78 commit 9998a69
Show file tree
Hide file tree
Showing 83 changed files with 7,234 additions and 11,826 deletions.
3 changes: 1 addition & 2 deletions .dumirc.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { defineConfig } from 'dumi';

// const publicPath = process.env.NODE_ENV === 'development' ? '/' : '/ld/o-orange/';
const publicPath = process.env.NODE_ENV === 'development' ? '/' : '/o-orange/';
const publicPath = process.env.NODE_ENV === 'development' ? '/' : process.env.PUBLIC_PATH;

export default defineConfig({
publicPath,
Expand Down
78 changes: 63 additions & 15 deletions __tests__/toUnit.test.js
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萬億');
})
9 changes: 0 additions & 9 deletions docs/.dumi/tmp/core/EmptyRoute.tsx

This file was deleted.

16 changes: 0 additions & 16 deletions docs/.dumi/tmp/core/defineApp.ts

This file was deleted.

11 changes: 0 additions & 11 deletions docs/.dumi/tmp/core/exportStaticRuntimePlugin.ts

This file was deleted.

10 changes: 0 additions & 10 deletions docs/.dumi/tmp/core/helmet.ts

This file was deleted.

4 changes: 0 additions & 4 deletions docs/.dumi/tmp/core/helmetContext.ts

This file was deleted.

66 changes: 0 additions & 66 deletions docs/.dumi/tmp/core/history.ts

This file was deleted.

132 changes: 0 additions & 132 deletions docs/.dumi/tmp/core/historyIntelli.ts

This file was deleted.

Loading

0 comments on commit 9998a69

Please sign in to comment.