Repository navigation
Expand file tree
/
Copy pathbalance.test-d.ts
More file actions
87 lines (81 loc) · 1.87 KB
/
Copy pathbalance.test-d.ts
File metadata and controls
87 lines (81 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import { expectAssignable, expectNotAssignable } from 'tsd';
import type { Balance } from './balance';
// Valid balances with all required fields
expectAssignable<Balance>({
amount: '1.0',
unit: 'ETH',
rawAmount: '1000000000000000000',
});
expectAssignable<Balance>({
amount: '0.1',
unit: 'BTC',
rawAmount: '10000000',
});
expectAssignable<Balance>({
amount: '.1',
unit: 'gwei',
rawAmount: '100000000',
});
expectAssignable<Balance>({
amount: '.1',
unit: 'wei',
rawAmount: '100000000',
});
expectAssignable<Balance>({
amount: '1.',
unit: 'sat',
rawAmount: '100000000',
});
// Missing rawAmount
expectNotAssignable<Balance>({ amount: '1.0', unit: 'ETH' });
// Invalid amount types
expectNotAssignable<Balance>({
amount: 1,
unit: 'ETH',
rawAmount: '1000000000000000000',
});
expectNotAssignable<Balance>({
amount: true,
unit: 'ETH',
rawAmount: '1000000000000000000',
});
expectNotAssignable<Balance>({
amount: undefined,
unit: 'ETH',
rawAmount: '1000000000000000000',
});
expectNotAssignable<Balance>({
amount: null,
unit: 'ETH',
rawAmount: '1000000000000000000',
});
// Invalid unit types
expectNotAssignable<Balance>({
amount: '1.0',
unit: 1,
rawAmount: '1000000000000000000',
});
expectNotAssignable<Balance>({
amount: '1.0',
unit: true,
rawAmount: '1000000000000000000',
});
expectNotAssignable<Balance>({
amount: '1.0',
unit: undefined,
rawAmount: '1000000000000000000',
});
expectNotAssignable<Balance>({
amount: '1.0',
unit: null,
rawAmount: '1000000000000000000',
});
// Invalid rawAmount types
expectNotAssignable<Balance>({ amount: '1.0', unit: 'ETH', rawAmount: 1 });
expectNotAssignable<Balance>({ amount: '1.0', unit: 'ETH', rawAmount: true });
expectNotAssignable<Balance>({
amount: '1.0',
unit: 'ETH',
rawAmount: undefined,
});
expectNotAssignable<Balance>({ amount: '1.0', unit: 'ETH', rawAmount: null });