@@ -4,91 +4,73 @@ import {
44 normalizeSafeAddress ,
55} from './address' ;
66
7- type TestAddress = {
8- address : string ;
9- normalizedAddress : string ;
10- checksumAddress : string ;
11- } ;
12-
13- const ETH_ADDRESSES = [
14- // Lower-case address
15- {
16- address : '0x6431726eee67570bf6f0cf892ae0a3988f03903f' ,
17- normalizedAddress : '0x6431726eee67570bf6f0cf892ae0a3988f03903f' ,
18- checksumAddress : '0x6431726EEE67570BF6f0Cf892aE0a3988F03903F' ,
19- } ,
20- // Checksum address
21- {
22- address : '0x6431726EEE67570BF6f0Cf892aE0a3988F03903F' ,
23- normalizedAddress : '0x6431726eee67570bf6f0cf892ae0a3988f03903f' ,
24- checksumAddress : '0x6431726EEE67570BF6f0Cf892aE0a3988F03903F' ,
25- } ,
26- ] ;
7+ describe ( 'address' , ( ) => {
8+ const TEST_CASES_EVM_ADDRESSES = [
9+ {
10+ address : '0x6431726eee67570bf6f0cf892ae0a3988f03903f' , // Lower-case address
11+ normalizedAddress : '0x6431726eee67570bf6f0cf892ae0a3988f03903f' ,
12+ checksumAddress : '0x6431726EEE67570BF6f0Cf892aE0a3988F03903F' ,
13+ } ,
14+ {
15+ address : '0x6431726EEE67570BF6f0Cf892aE0a3988F03903F' , // Checksum address
16+ normalizedAddress : '0x6431726eee67570bf6f0cf892ae0a3988f03903f' ,
17+ checksumAddress : '0x6431726EEE67570BF6f0Cf892aE0a3988F03903F' ,
18+ } ,
19+ ] ;
2720
28- const NON_EVM_ADDRESSES = [
29- {
30- address : '0xdeadbeef' ,
31- } ,
32- {
33- address : 'bc1ql49ydapnjafl5t2cp9zqpjwe6pdgmxy98859v2' ,
34- } ,
35- ] ;
21+ const TEST_CASES_NON_EVM_ADDRESSES = [
22+ '0xdeadbeef' ,
23+ 'bc1ql49ydapnjafl5t2cp9zqpjwe6pdgmxy98859v2' ,
24+ ] ;
3625
37- describe ( 'address' , ( ) => {
3826 describe ( 'isEthAddress' , ( ) => {
39- // @ts -expect-error This is missing from the Mocha type definitions
40- it . each ( ETH_ADDRESSES ) (
27+ it . each ( TEST_CASES_EVM_ADDRESSES ) (
4128 'returns true if address is an ethereum address: $address' ,
42- ( { address } : TestAddress ) => {
29+ ( { address } ) => {
4330 expect ( isEthAddress ( address ) ) . toBe ( true ) ;
4431 expect ( isEthAddress ( address . toLowerCase ( ) ) ) . toBe ( true ) ;
4532 } ,
4633 ) ;
4734
48- // @ts -expect-error This is missing from the Mocha type definitions
49- it . each ( NON_EVM_ADDRESSES ) (
35+ it . each ( TEST_CASES_NON_EVM_ADDRESSES ) (
5036 'returns false if address is not an ethereum address: $address' ,
51- ( { address } : TestAddress ) => {
37+ ( address ) => {
5238 expect ( isEthAddress ( address ) ) . toBe ( false ) ;
5339 } ,
5440 ) ;
5541 } ) ;
5642
5743 describe ( 'normalizeAddress' , ( ) => {
58- // @ts -expect-error This is missing from the Mocha type definitions
59- it . each ( ETH_ADDRESSES ) (
44+ it . each ( TEST_CASES_EVM_ADDRESSES ) (
6045 'normalizes address: $address' ,
61- ( { address, normalizedAddress } : TestAddress ) => {
46+ ( { address, normalizedAddress } ) => {
6247 expect ( normalizeAddress ( address ) ) . toBe ( normalizedAddress ) ;
6348 expect ( normalizeAddress ( address . toLowerCase ( ) ) ) . toBe ( normalizedAddress ) ;
6449 } ,
6550 ) ;
6651
67- // @ts -expect-error This is missing from the Mocha type definitions
68- it . each ( NON_EVM_ADDRESSES ) (
52+ it . each ( TEST_CASES_NON_EVM_ADDRESSES ) (
6953 'returns the original address if its a non-EVM address' ,
70- ( { address } : TestAddress ) => {
54+ ( address ) => {
7155 expect ( normalizeAddress ( address ) ) . toBe ( address ) ;
7256 } ,
7357 ) ;
7458 } ) ;
7559
7660 describe ( 'normalizeSafeAddress' , ( ) => {
77- // @ts -expect-error This is missing from the Mocha type definitions
78- it . each ( ETH_ADDRESSES ) (
61+ it . each ( TEST_CASES_EVM_ADDRESSES ) (
7962 'normalizes address to its "safe" form: $address to: $checksumAddress' ,
80- ( { address, checksumAddress } : TestAddress ) => {
63+ ( { address, checksumAddress } ) => {
8164 expect ( normalizeSafeAddress ( address ) ) . toBe ( checksumAddress ) ;
8265 expect ( normalizeSafeAddress ( address . toLowerCase ( ) ) ) . toBe (
8366 checksumAddress ,
8467 ) ;
8568 } ,
8669 ) ;
8770
88- // @ts -expect-error This is missing from the Mocha type definitions
89- it . each ( NON_EVM_ADDRESSES ) (
71+ it . each ( TEST_CASES_NON_EVM_ADDRESSES ) (
9072 'returns the original address if its a non-EVM address' ,
91- ( { address } : TestAddress ) => {
73+ ( address ) => {
9274 expect ( normalizeSafeAddress ( address ) ) . toBe ( address ) ;
9375 } ,
9476 ) ;
0 commit comments