@@ -16,9 +16,10 @@ You should have received a copy of the GNU Lesser General Public License
1616along with the library. If not, see <http://www.gnu.org/licenses/>.
1717*/
1818
19- import { TokenList } from '../lib/types'
20- import mainnetJson from './../tokens/mainnet.json'
21- import testnetJson from './../tokens/testnet.json'
19+ import { TokenList } from '../../lib/types'
20+ import mainnetJson from '../../tokens/mainnet.json'
21+ import testnetJson from '../../tokens/testnet.json'
22+ import { checkDuplicates } from '../utils'
2223import devnetJson from './devnet.json'
2324
2425const mainnetTokenList = mainnetJson as TokenList
@@ -29,7 +30,7 @@ const tokenLists = [mainnetTokenList, testnetTokenList, devnetTokenList]
2930
3031describe ( 'TokenList' , function ( ) {
3132 it ( 'should contains no duplicate' , ( ) => {
32- tokenLists . forEach ( checkDuplicates )
33+ tokenLists . forEach ( ( tokenList ) => checkDuplicates ( tokenList . tokens ) )
3334 } )
3435
3536 it ( 'should have valid logoURI' , ( ) => {
@@ -64,27 +65,3 @@ describe('TokenList', function () {
6465 expect ( testnetJson . networkId ) . toEqual ( 1 )
6566 } )
6667} )
67-
68- function checkDuplicates ( tokenList : TokenList ) : void {
69- const ids = new Map < string , boolean > ( )
70- const names = new Map < string , boolean > ( )
71- const symbols = new Map < string , boolean > ( )
72-
73- const tokensLike = ( tokenList . tokens as { id : string ; name : string ; symbol : string } [ ] ) . concat (
74- tokenList . nftCollections
75- )
76-
77- for ( const token of tokensLike ) {
78- //Ids
79- expect ( ids . get ( token . id ) ) . toBeUndefined ( )
80- ids . set ( token . id , true )
81-
82- //Name
83- expect ( names . get ( token . name ) ) . toBeUndefined ( )
84- names . set ( token . name , true )
85-
86- //Symbol
87- expect ( symbols . get ( token . symbol ) ) . toBeUndefined ( )
88- symbols . set ( token . symbol , true )
89- }
90- }
0 commit comments