@morpho-org/blue-sdk 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/addresses.d.ts +156 -0
- package/lib/addresses.js +160 -0
- package/lib/chain/chain.constants.d.ts +3 -0
- package/lib/chain/chain.constants.js +232 -0
- package/lib/chain/chain.test.d.ts +1 -0
- package/lib/chain/chain.test.js +37 -0
- package/lib/chain/chain.types.d.ts +20 -0
- package/lib/chain/chain.types.js +30 -0
- package/lib/chain/chain.utils.d.ts +14 -0
- package/lib/chain/chain.utils.js +30 -0
- package/lib/chain/index.js +18 -0
- package/lib/constants.d.ts +8 -0
- package/lib/constants.js +13 -0
- package/lib/errors.d.ts +37 -0
- package/lib/errors.js +71 -0
- package/lib/ethers/ethers.test.d.ts +1 -0
- package/lib/ethers/ethers.test.js +11 -0
- package/lib/ethers/index.js +18 -0
- package/lib/ethers/safeGetAddress.d.ts +1 -0
- package/lib/ethers/safeGetAddress.js +6 -0
- package/lib/ethers/safeParseUnits.d.ts +2 -0
- package/lib/ethers/safeParseUnits.js +25 -0
- package/lib/evm.d.ts +36 -0
- package/lib/evm.js +113 -0
- package/lib/helpers/format/format.d.ts +98 -0
- package/lib/helpers/format/format.js +301 -0
- package/lib/helpers/format/format.test.d.ts +1 -0
- package/lib/helpers/format/format.test.js +257 -0
- package/lib/helpers/format/index.js +17 -0
- package/lib/helpers/getChecksumedAddress.d.ts +7 -0
- package/lib/helpers/getChecksumedAddress.js +17 -0
- package/lib/helpers/index.js +20 -0
- package/{src/helpers/isZeroAddressOrUnset.ts → lib/helpers/isZeroAddressOrUnset.d.ts} +1 -7
- package/lib/helpers/isZeroAddressOrUnset.js +14 -0
- package/lib/helpers/locale.d.ts +36 -0
- package/lib/helpers/locale.js +86 -0
- package/lib/holding/Holding.d.ts +60 -0
- package/lib/holding/Holding.js +31 -0
- package/lib/holding/index.js +17 -0
- package/{src/index.ts → lib/index.d.ts} +0 -1
- package/lib/index.js +62 -0
- package/lib/market/Market.d.ts +159 -0
- package/lib/market/Market.js +240 -0
- package/lib/market/MarketConfig.d.ts +44 -0
- package/lib/market/MarketConfig.js +56 -0
- package/lib/market/MarketUtils.d.ts +165 -0
- package/lib/market/MarketUtils.js +182 -0
- package/lib/market/MarketUtils.test.d.ts +1 -0
- package/lib/market/MarketUtils.test.js +19 -0
- package/lib/market/index.js +19 -0
- package/lib/maths/AdaptiveCurveIrmLib.d.ts +37 -0
- package/lib/maths/AdaptiveCurveIrmLib.js +116 -0
- package/lib/maths/MathLib.d.ts +94 -0
- package/lib/maths/MathLib.js +153 -0
- package/lib/maths/MathUtils.d.ts +15 -0
- package/lib/maths/MathUtils.js +33 -0
- package/lib/maths/SharesMath.d.ts +12 -0
- package/lib/maths/SharesMath.js +22 -0
- package/lib/maths/index.js +20 -0
- package/lib/notifications.d.ts +98 -0
- package/lib/notifications.js +52 -0
- package/lib/position/Position.d.ts +118 -0
- package/lib/position/Position.js +145 -0
- package/lib/position/index.js +17 -0
- package/lib/signatures/index.d.ts +12 -0
- package/lib/signatures/index.js +39 -0
- package/lib/signatures/manager.d.ts +10 -0
- package/lib/signatures/manager.js +37 -0
- package/lib/signatures/permit.d.ts +21 -0
- package/lib/signatures/permit.js +101 -0
- package/lib/signatures/permit2.d.ts +20 -0
- package/lib/signatures/permit2.js +91 -0
- package/lib/signatures/types.d.ts +13 -0
- package/lib/signatures/types.js +2 -0
- package/lib/signatures/utils.d.ts +6 -0
- package/lib/signatures/utils.js +44 -0
- package/lib/tests/mocks/markets.d.ts +17 -0
- package/lib/tests/mocks/markets.js +108 -0
- package/lib/token/ERC20Metadata.d.ts +249 -0
- package/lib/token/ERC20Metadata.js +81 -0
- package/lib/token/Token.d.ts +45 -0
- package/lib/token/Token.js +39 -0
- package/lib/token/TokenNamespace.d.ts +18 -0
- package/lib/token/TokenNamespace.js +55 -0
- package/lib/token/WrappedToken.d.ts +42 -0
- package/lib/token/WrappedToken.js +87 -0
- package/lib/token/index.js +18 -0
- package/lib/types.d.ts +29 -0
- package/lib/types.js +23 -0
- package/lib/user/User.d.ts +20 -0
- package/lib/user/User.js +11 -0
- package/lib/user/index.js +18 -0
- package/lib/user/user.types.d.ts +18 -0
- package/lib/user/user.types.js +2 -0
- package/lib/vault/Vault.d.ts +167 -0
- package/lib/vault/Vault.js +156 -0
- package/lib/vault/VaultAllocation.d.ts +38 -0
- package/lib/vault/VaultAllocation.js +18 -0
- package/lib/vault/VaultConfig.d.ts +23 -0
- package/lib/vault/VaultConfig.js +26 -0
- package/lib/vault/VaultUtils.d.ts +17 -0
- package/lib/vault/VaultUtils.js +17 -0
- package/lib/vault/index.js +20 -0
- package/package.json +7 -11
- package/src/addresses.ts +0 -261
- package/src/chain/chain.constants.ts +0 -235
- package/src/chain/chain.test.ts +0 -51
- package/src/chain/chain.types.ts +0 -42
- package/src/chain/chain.utils.ts +0 -44
- package/src/constants.ts +0 -18
- package/src/errors.ts +0 -75
- package/src/ethers/ethers.test.ts +0 -17
- package/src/ethers/safeGetAddress.ts +0 -4
- package/src/ethers/safeParseUnits.ts +0 -29
- package/src/evm.ts +0 -172
- package/src/helpers/format/format.test.ts +0 -340
- package/src/helpers/format/format.ts +0 -416
- package/src/helpers/getChecksumedAddress.ts +0 -15
- package/src/helpers/locale.ts +0 -108
- package/src/holding/Holding.ts +0 -109
- package/src/market/Market.ts +0 -479
- package/src/market/MarketConfig.ts +0 -108
- package/src/market/MarketUtils.test.ts +0 -25
- package/src/market/MarketUtils.ts +0 -467
- package/src/maths/AdaptiveCurveIrmLib.ts +0 -143
- package/src/maths/MathLib.ts +0 -208
- package/src/maths/MathUtils.ts +0 -31
- package/src/maths/SharesMath.ts +0 -40
- package/src/notifications.ts +0 -167
- package/src/position/Position.ts +0 -251
- package/src/signatures/index.ts +0 -18
- package/src/signatures/manager.ts +0 -50
- package/src/signatures/permit.ts +0 -126
- package/src/signatures/permit2.ts +0 -120
- package/src/signatures/types.ts +0 -18
- package/src/signatures/utils.ts +0 -83
- package/src/tests/mocks/markets.ts +0 -110
- package/src/token/ERC20Metadata.ts +0 -124
- package/src/token/Token.ts +0 -83
- package/src/token/TokenNamespace.ts +0 -76
- package/src/token/WrappedToken.ts +0 -142
- package/src/types.ts +0 -37
- package/src/user/User.ts +0 -32
- package/src/user/user.types.ts +0 -23
- package/src/vault/Vault.ts +0 -370
- package/src/vault/VaultAllocation.ts +0 -58
- package/src/vault/VaultConfig.ts +0 -55
- package/src/vault/VaultUtils.ts +0 -47
- /package/{src/chain/index.ts → lib/chain/index.d.ts} +0 -0
- /package/{src/ethers/index.ts → lib/ethers/index.d.ts} +0 -0
- /package/{src/helpers/format/index.ts → lib/helpers/format/index.d.ts} +0 -0
- /package/{src/helpers/index.ts → lib/helpers/index.d.ts} +0 -0
- /package/{src/holding/index.ts → lib/holding/index.d.ts} +0 -0
- /package/{src/market/index.ts → lib/market/index.d.ts} +0 -0
- /package/{src/maths/index.ts → lib/maths/index.d.ts} +0 -0
- /package/{src/position/index.ts → lib/position/index.d.ts} +0 -0
- /package/{src/token/index.ts → lib/token/index.d.ts} +0 -0
- /package/{src/user/index.ts → lib/user/index.d.ts} +0 -0
- /package/{src/vault/index.ts → lib/vault/index.d.ts} +0 -0
|
@@ -1,340 +0,0 @@
|
|
|
1
|
-
import { format } from "./format";
|
|
2
|
-
|
|
3
|
-
describe("format", () => {
|
|
4
|
-
const number = 12345.6789;
|
|
5
|
-
const bigint = 123456789n;
|
|
6
|
-
const decimals = 4;
|
|
7
|
-
|
|
8
|
-
describe("hex", () => {
|
|
9
|
-
describe("should properly format number in hex format", () => {
|
|
10
|
-
it("without option", () => {
|
|
11
|
-
expect(format.hex.of(number)).toEqual((123456789).toString(16));
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
describe("should properly format bigint in hex format", () => {
|
|
15
|
-
it("without option", () => {
|
|
16
|
-
expect(format.hex.of(bigint, decimals)).toEqual(
|
|
17
|
-
(123456789).toString(16)
|
|
18
|
-
);
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
describe("number", () => {
|
|
24
|
-
describe("should properly format number in number format", () => {
|
|
25
|
-
it("without option", () => {
|
|
26
|
-
expect(format.number.of(number)).toEqual("12345.6789");
|
|
27
|
-
});
|
|
28
|
-
it("with digits", () => {
|
|
29
|
-
expect(format.number.digits(2).of(number)).toEqual("12345.67");
|
|
30
|
-
});
|
|
31
|
-
it("with min", () => {
|
|
32
|
-
expect(format.number.min(20000).of(number)).toEqual("< 20000.0000");
|
|
33
|
-
});
|
|
34
|
-
it("with max", () => {
|
|
35
|
-
expect(format.number.max(10000).of(number)).toEqual("> 10000.0000");
|
|
36
|
-
});
|
|
37
|
-
it("with sign", () => {
|
|
38
|
-
expect(format.number.sign().of(number)).toEqual("+12345.6789");
|
|
39
|
-
});
|
|
40
|
-
it("with unit", () => {
|
|
41
|
-
expect(format.number.unit("$").of(number)).toEqual("$12345.6789");
|
|
42
|
-
});
|
|
43
|
-
it("without trailing zeros", () => {
|
|
44
|
-
expect(format.number.digits(6).of(number)).toEqual("12345.678900");
|
|
45
|
-
expect(format.number.digits(6).removeTrailingZero().of(number)).toEqual(
|
|
46
|
-
"12345.6789"
|
|
47
|
-
);
|
|
48
|
-
});
|
|
49
|
-
it("with locale", () => {
|
|
50
|
-
expect(format.number.locale("fr-FR").of(number)).toEqual("12345,6789");
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
describe("should properly format bigint in number format", () => {
|
|
54
|
-
it("without option", () => {
|
|
55
|
-
expect(format.number.of(bigint, decimals)).toEqual("12345.6789");
|
|
56
|
-
});
|
|
57
|
-
it("with digits", () => {
|
|
58
|
-
expect(format.number.digits(2).of(bigint, decimals)).toEqual(
|
|
59
|
-
"12345.67"
|
|
60
|
-
);
|
|
61
|
-
});
|
|
62
|
-
it("with min", () => {
|
|
63
|
-
expect(format.number.min(20000).of(bigint, decimals)).toEqual(
|
|
64
|
-
"< 20000.0000"
|
|
65
|
-
);
|
|
66
|
-
});
|
|
67
|
-
it("with max", () => {
|
|
68
|
-
expect(format.number.max(10000).of(bigint, decimals)).toEqual(
|
|
69
|
-
"> 10000.0000"
|
|
70
|
-
);
|
|
71
|
-
});
|
|
72
|
-
it("with sign", () => {
|
|
73
|
-
expect(format.number.sign().of(bigint, decimals)).toEqual(
|
|
74
|
-
"+12345.6789"
|
|
75
|
-
);
|
|
76
|
-
});
|
|
77
|
-
it("with unit", () => {
|
|
78
|
-
expect(format.number.unit("$").of(bigint, decimals)).toEqual(
|
|
79
|
-
"$12345.6789"
|
|
80
|
-
);
|
|
81
|
-
});
|
|
82
|
-
it("without trailing zeros", () => {
|
|
83
|
-
expect(format.number.digits(6).of(bigint, decimals)).toEqual(
|
|
84
|
-
"12345.678900"
|
|
85
|
-
);
|
|
86
|
-
expect(
|
|
87
|
-
format.number.digits(6).removeTrailingZero().of(bigint, decimals)
|
|
88
|
-
).toEqual("12345.6789");
|
|
89
|
-
});
|
|
90
|
-
it("with locale", () => {
|
|
91
|
-
expect(format.number.locale("fr-FR").of(bigint, decimals)).toEqual(
|
|
92
|
-
"12345,6789"
|
|
93
|
-
);
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
describe("short", () => {
|
|
99
|
-
describe("should properly format number in short format", () => {
|
|
100
|
-
it("without option", () => {
|
|
101
|
-
expect(format.short.of(number)).toEqual("12.3456789k");
|
|
102
|
-
});
|
|
103
|
-
it("with digits", () => {
|
|
104
|
-
expect(format.short.digits(2).of(number)).toEqual("12.34k");
|
|
105
|
-
});
|
|
106
|
-
it("with min", () => {
|
|
107
|
-
expect(format.short.min(20000).of(number)).toEqual("< 20.0000000k");
|
|
108
|
-
});
|
|
109
|
-
it("with max", () => {
|
|
110
|
-
expect(format.short.max(10000).of(number)).toEqual("> 10.0000000k");
|
|
111
|
-
});
|
|
112
|
-
it("with sign", () => {
|
|
113
|
-
expect(format.short.sign().of(number)).toEqual("+12.3456789k");
|
|
114
|
-
});
|
|
115
|
-
it("with unit", () => {
|
|
116
|
-
expect(format.short.unit("€").of(number)).toEqual("12.3456789k €");
|
|
117
|
-
});
|
|
118
|
-
it("without trailing zeros", () => {
|
|
119
|
-
expect(format.short.digits(8).of(number)).toEqual("12.34567890k");
|
|
120
|
-
expect(format.short.digits(8).removeTrailingZero().of(number)).toEqual(
|
|
121
|
-
"12.3456789k"
|
|
122
|
-
);
|
|
123
|
-
});
|
|
124
|
-
it("with small numbers with commas", () => {
|
|
125
|
-
expect(format.short.smallValuesWithCommas().of(number / 10)).toEqual(
|
|
126
|
-
"1,234.56789"
|
|
127
|
-
);
|
|
128
|
-
});
|
|
129
|
-
it("with locale", () => {
|
|
130
|
-
expect(format.short.locale("fr-FR").of(number)).toEqual("12,3456789k");
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
describe("should properly format bigint in short format", () => {
|
|
134
|
-
it("without option", () => {
|
|
135
|
-
expect(format.short.of(bigint, decimals)).toEqual("12.3456789k");
|
|
136
|
-
});
|
|
137
|
-
it("with digits", () => {
|
|
138
|
-
expect(format.short.digits(2).of(bigint, decimals)).toEqual("12.34k");
|
|
139
|
-
});
|
|
140
|
-
it("with min", () => {
|
|
141
|
-
expect(format.short.min(20000).of(bigint, decimals)).toEqual(
|
|
142
|
-
"< 20.0000000k"
|
|
143
|
-
);
|
|
144
|
-
});
|
|
145
|
-
it("with max", () => {
|
|
146
|
-
expect(format.short.max(10000).of(bigint, decimals)).toEqual(
|
|
147
|
-
"> 10.0000000k"
|
|
148
|
-
);
|
|
149
|
-
});
|
|
150
|
-
it("with sign", () => {
|
|
151
|
-
expect(format.short.sign().of(bigint, decimals)).toEqual(
|
|
152
|
-
"+12.3456789k"
|
|
153
|
-
);
|
|
154
|
-
});
|
|
155
|
-
it("with unit", () => {
|
|
156
|
-
expect(format.short.unit("€").of(bigint, decimals)).toEqual(
|
|
157
|
-
"12.3456789k €"
|
|
158
|
-
);
|
|
159
|
-
});
|
|
160
|
-
it("without trailing zeros", () => {
|
|
161
|
-
expect(format.short.digits(8).of(bigint, decimals)).toEqual(
|
|
162
|
-
"12.34567890k"
|
|
163
|
-
);
|
|
164
|
-
expect(
|
|
165
|
-
format.short.digits(8).removeTrailingZero().of(bigint, decimals)
|
|
166
|
-
).toEqual("12.3456789k");
|
|
167
|
-
});
|
|
168
|
-
it("with locale", () => {
|
|
169
|
-
expect(format.short.locale("fr-FR").of(bigint, decimals)).toEqual(
|
|
170
|
-
"12,3456789k"
|
|
171
|
-
);
|
|
172
|
-
});
|
|
173
|
-
it("with small numbers with commas", () => {
|
|
174
|
-
expect(
|
|
175
|
-
format.short.smallValuesWithCommas().of(bigint, decimals + 1)
|
|
176
|
-
).toEqual("1,234.56789");
|
|
177
|
-
});
|
|
178
|
-
it("with small numbers with commas with locale", () => {
|
|
179
|
-
expect(
|
|
180
|
-
format.short
|
|
181
|
-
.smallValuesWithCommas()
|
|
182
|
-
.locale("fr-FR")
|
|
183
|
-
.of(bigint, decimals + 1)
|
|
184
|
-
// the correct space in fr-FR is narrow no-break space (U+202F)
|
|
185
|
-
).toEqual("1\u202F234,56789");
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
describe("commas", () => {
|
|
191
|
-
describe("should properly format number in commas format", () => {
|
|
192
|
-
it("without option", () => {
|
|
193
|
-
expect(format.commas.of(number)).toEqual("12,345.6789");
|
|
194
|
-
});
|
|
195
|
-
it("with digits", () => {
|
|
196
|
-
expect(format.commas.digits(2).of(number)).toEqual("12,345.67");
|
|
197
|
-
});
|
|
198
|
-
it("with min", () => {
|
|
199
|
-
expect(format.commas.min(20000).of(number)).toEqual("< 20,000.0000");
|
|
200
|
-
});
|
|
201
|
-
it("with max", () => {
|
|
202
|
-
expect(format.commas.max(10000).of(number)).toEqual("> 10,000.0000");
|
|
203
|
-
});
|
|
204
|
-
it("with sign", () => {
|
|
205
|
-
expect(format.commas.sign().of(number)).toEqual("+12,345.6789");
|
|
206
|
-
});
|
|
207
|
-
it("with unit", () => {
|
|
208
|
-
expect(format.commas.unit("ETH").of(number)).toEqual("12,345.6789 ETH");
|
|
209
|
-
});
|
|
210
|
-
it("without trailing zeros", () => {
|
|
211
|
-
expect(format.commas.digits(6).of(number)).toEqual("12,345.678900");
|
|
212
|
-
expect(format.commas.digits(6).removeTrailingZero().of(number)).toEqual(
|
|
213
|
-
"12,345.6789"
|
|
214
|
-
);
|
|
215
|
-
});
|
|
216
|
-
it("with locale", () => {
|
|
217
|
-
expect(format.commas.locale("fr-FR").of(number)).toEqual(
|
|
218
|
-
"12\u202F345,6789"
|
|
219
|
-
);
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
describe("should properly format bigint in commas format", () => {
|
|
223
|
-
it("without option", () => {
|
|
224
|
-
expect(format.commas.of(bigint, decimals)).toEqual("12,345.6789");
|
|
225
|
-
});
|
|
226
|
-
it("with digits", () => {
|
|
227
|
-
expect(format.commas.digits(2).of(bigint, decimals)).toEqual(
|
|
228
|
-
"12,345.67"
|
|
229
|
-
);
|
|
230
|
-
});
|
|
231
|
-
it("with min", () => {
|
|
232
|
-
expect(format.commas.min(20000).of(bigint, decimals)).toEqual(
|
|
233
|
-
"< 20,000.0000"
|
|
234
|
-
);
|
|
235
|
-
});
|
|
236
|
-
it("with max", () => {
|
|
237
|
-
expect(format.commas.max(10000).of(bigint, decimals)).toEqual(
|
|
238
|
-
"> 10,000.0000"
|
|
239
|
-
);
|
|
240
|
-
});
|
|
241
|
-
it("with sign", () => {
|
|
242
|
-
expect(format.commas.sign().of(bigint, decimals)).toEqual(
|
|
243
|
-
"+12,345.6789"
|
|
244
|
-
);
|
|
245
|
-
});
|
|
246
|
-
it("with unit", () => {
|
|
247
|
-
expect(format.commas.unit("ETH").of(bigint, decimals)).toEqual(
|
|
248
|
-
"12,345.6789 ETH"
|
|
249
|
-
);
|
|
250
|
-
});
|
|
251
|
-
it("without trailing zeros", () => {
|
|
252
|
-
expect(format.commas.digits(6).of(bigint, decimals)).toEqual(
|
|
253
|
-
"12,345.678900"
|
|
254
|
-
);
|
|
255
|
-
expect(
|
|
256
|
-
format.commas.digits(6).removeTrailingZero().of(bigint, decimals)
|
|
257
|
-
).toEqual("12,345.6789");
|
|
258
|
-
});
|
|
259
|
-
it("with locale", () => {
|
|
260
|
-
// the correct space in fr-FR is narrow no-break space (U+202F)
|
|
261
|
-
expect(format.commas.locale("fr-FR").of(bigint, decimals)).toEqual(
|
|
262
|
-
"12\u202F345,6789"
|
|
263
|
-
);
|
|
264
|
-
});
|
|
265
|
-
});
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
describe("percent", () => {
|
|
269
|
-
describe("should properly format number in percent format", () => {
|
|
270
|
-
it("without option", () => {
|
|
271
|
-
expect(format.percent.of(number)).toEqual("1234567.8900");
|
|
272
|
-
});
|
|
273
|
-
it("with digits", () => {
|
|
274
|
-
expect(format.percent.digits(1).of(number)).toEqual("1234567.8");
|
|
275
|
-
});
|
|
276
|
-
it("with min", () => {
|
|
277
|
-
expect(format.percent.min(20000).of(number)).toEqual("< 2000000.0000");
|
|
278
|
-
});
|
|
279
|
-
it("with max", () => {
|
|
280
|
-
expect(format.percent.max(10000).of(number)).toEqual("> 1000000.0000");
|
|
281
|
-
});
|
|
282
|
-
it("with sign", () => {
|
|
283
|
-
expect(format.percent.sign().of(number)).toEqual("+1234567.8900");
|
|
284
|
-
});
|
|
285
|
-
it("with unit", () => {
|
|
286
|
-
expect(format.percent.unit("%").of(number)).toEqual("1234567.8900%");
|
|
287
|
-
});
|
|
288
|
-
it("without trailing zeros", () => {
|
|
289
|
-
expect(format.percent.removeTrailingZero().of(number)).toEqual(
|
|
290
|
-
"1234567.89"
|
|
291
|
-
);
|
|
292
|
-
});
|
|
293
|
-
it("with locale", () => {
|
|
294
|
-
expect(format.percent.locale("fr-FR").of(number)).toEqual(
|
|
295
|
-
"1234567,8900"
|
|
296
|
-
);
|
|
297
|
-
});
|
|
298
|
-
});
|
|
299
|
-
describe("should properly format bigint in percent format", () => {
|
|
300
|
-
it("without option", () => {
|
|
301
|
-
expect(format.percent.of(bigint, decimals)).toEqual("1234567.8900");
|
|
302
|
-
});
|
|
303
|
-
it("with digits", () => {
|
|
304
|
-
expect(format.percent.digits(1).of(bigint, decimals)).toEqual(
|
|
305
|
-
"1234567.8"
|
|
306
|
-
);
|
|
307
|
-
});
|
|
308
|
-
it("with min", () => {
|
|
309
|
-
expect(format.percent.min(20000).of(bigint, decimals)).toEqual(
|
|
310
|
-
"< 2000000.0000"
|
|
311
|
-
);
|
|
312
|
-
});
|
|
313
|
-
it("with max", () => {
|
|
314
|
-
expect(format.percent.max(10000).of(bigint, decimals)).toEqual(
|
|
315
|
-
"> 1000000.0000"
|
|
316
|
-
);
|
|
317
|
-
});
|
|
318
|
-
it("with sign", () => {
|
|
319
|
-
expect(format.percent.sign().of(bigint, decimals)).toEqual(
|
|
320
|
-
"+1234567.8900"
|
|
321
|
-
);
|
|
322
|
-
});
|
|
323
|
-
it("with unit", () => {
|
|
324
|
-
expect(format.percent.unit("%").of(bigint, decimals)).toEqual(
|
|
325
|
-
"1234567.8900%"
|
|
326
|
-
);
|
|
327
|
-
});
|
|
328
|
-
it("without trailing zeros", () => {
|
|
329
|
-
expect(
|
|
330
|
-
format.percent.removeTrailingZero().of(bigint, decimals)
|
|
331
|
-
).toEqual("1234567.89");
|
|
332
|
-
});
|
|
333
|
-
it("with locale", () => {
|
|
334
|
-
expect(format.percent.locale("fr-FR").of(bigint, decimals)).toEqual(
|
|
335
|
-
"1234567,8900"
|
|
336
|
-
);
|
|
337
|
-
});
|
|
338
|
-
});
|
|
339
|
-
});
|
|
340
|
-
});
|