aboutsummaryrefslogtreecommitdiffstats
path: root/test/token_registry_wrapper_test.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-08-23 23:27:54 +0800
committerFabio Berger <me@fabioberger.com>2017-08-23 23:27:54 +0800
commitfedded3ec1d3051589777a61aba14720432f1d51 (patch)
tree28ad7ff17a979930dacdc8a7ffd9fdeaed27edf2 /test/token_registry_wrapper_test.ts
parentd837e27739614ce6a132e8583409425f726bef89 (diff)
downloaddexon-sol-tools-fedded3ec1d3051589777a61aba14720432f1d51.tar
dexon-sol-tools-fedded3ec1d3051589777a61aba14720432f1d51.tar.gz
dexon-sol-tools-fedded3ec1d3051589777a61aba14720432f1d51.tar.bz2
dexon-sol-tools-fedded3ec1d3051589777a61aba14720432f1d51.tar.lz
dexon-sol-tools-fedded3ec1d3051589777a61aba14720432f1d51.tar.xz
dexon-sol-tools-fedded3ec1d3051589777a61aba14720432f1d51.tar.zst
dexon-sol-tools-fedded3ec1d3051589777a61aba14720432f1d51.zip
Add public method `getTokenMetadataIfExistsAsync` to TokenRegistry wrapper, refactor `getTokensAsync` to use `getTokenMetadataIfExistsAsync` under the hood and added unit tests
Diffstat (limited to 'test/token_registry_wrapper_test.ts')
-rw-r--r--test/token_registry_wrapper_test.ts16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/token_registry_wrapper_test.ts b/test/token_registry_wrapper_test.ts
index da436161c..a3e5adf6c 100644
--- a/test/token_registry_wrapper_test.ts
+++ b/test/token_registry_wrapper_test.ts
@@ -38,4 +38,20 @@ describe('TokenRegistryWrapper', () => {
});
});
});
+ describe('#getTokenMetadataIfExistsAsync', () => {
+ it('should return the token added to the tokenRegistry during the migration', async () => {
+ const tokens = await zeroEx.tokenRegistry.getTokensAsync();
+ const aToken = tokens[0];
+
+ const token = await zeroEx.tokenRegistry.getTokenMetadataIfExistsAsync(aToken.address);
+ const schemaValidator = new SchemaValidator();
+ const validationResult = schemaValidator.validate(token, tokenSchema);
+ expect(validationResult.errors).to.have.lengthOf(0);
+ });
+ it('should return return undefined when passed a token address not in the tokenRegistry', async () => {
+ const unregisteredTokenAddress = '0x5409ED021D9299bf6814279A6A1411A7e866A631';
+ const tokenIfExists = await zeroEx.tokenRegistry.getTokenMetadataIfExistsAsync(unregisteredTokenAddress);
+ expect(tokenIfExists).to.be.undefined();
+ });
+ });
});