UNPKG

@yoroi/portfolio

Version:

The Portfolio package of Yoroi SDK

133 lines (132 loc) 5.23 kB
"use strict"; var _tokenInfo = require("../adapters/token-info.mocks"); var _tokenInfo2 = require("./token-info"); describe('isPrimaryTokenInfo', () => { it('should return true for valid primary token info', () => { const result = (0, _tokenInfo2.isPrimaryTokenInfo)(_tokenInfo.tokenInfoMocks.primaryETH); expect(result).toBe(true); }); it('should return false for invalid primary token info', () => { const result = (0, _tokenInfo2.isPrimaryTokenInfo)(_tokenInfo.tokenInfoMocks.nftCryptoKitty); expect(result).toBe(false); }); }); describe('isSecondaryTokenInfo', () => { it('should return true for valid secondary token info', () => { const result = (0, _tokenInfo2.isSecondaryTokenInfo)(_tokenInfo.tokenInfoMocks.nftCryptoKitty); expect(result).toBe(true); }); it('should return false for invalid secondary token info', () => { const result = (0, _tokenInfo2.isSecondaryTokenInfo)(_tokenInfo.tokenInfoMocks.primaryETH); expect(result).toBe(false); }); }); describe('isTokenInfo', () => { it('should return true for valid token info', () => { const primaryTokenInfo = _tokenInfo.tokenInfoMocks.primaryETH; const secondaryTokenInfo = _tokenInfo.tokenInfoMocks.nftCryptoKitty; const result1 = (0, _tokenInfo2.isTokenInfo)(primaryTokenInfo); const result2 = (0, _tokenInfo2.isTokenInfo)(secondaryTokenInfo); expect(result1).toBe(true); expect(result2).toBe(true); }); it('should return false for invalid token info', () => { const invalidTokenInfo = { foo: 'bar' }; const result = (0, _tokenInfo2.isTokenInfo)(invalidTokenInfo); expect(result).toBe(false); }); }); describe('parseTokenInfo', () => { it('should return token info for valid input', () => { const primaryTokenInfo = _tokenInfo.tokenInfoMocks.primaryETH; const secondaryTokenInfo = _tokenInfo.tokenInfoMocks.nftCryptoKitty; const result1 = (0, _tokenInfo2.parseTokenInfo)(primaryTokenInfo); const result2 = (0, _tokenInfo2.parseTokenInfo)(secondaryTokenInfo); expect(result1).toEqual(primaryTokenInfo); expect(result2).toEqual(secondaryTokenInfo); }); it('should return undefined for invalid input', () => { const invalidTokenInfo = { foo: 'bar' }; const result = (0, _tokenInfo2.parseTokenInfo)(invalidTokenInfo); expect(result).toBeUndefined(); }); }); describe('isSecondaryTokenInfoWithCacheRecord', () => { it('should return true for valid token info response with cache record', () => { const validResponse = [200, _tokenInfo.tokenInfoMocks.nftCryptoKitty, 'hash', 100]; const result = (0, _tokenInfo2.isSecondaryTokenInfoWithCacheRecord)(validResponse); expect(result).toBe(true); }); it('should return false for invalid token info response with cache record', () => { const invalidResponse = { data: { foo: 'bar' }, cache: 'some-cache-value' }; const result = (0, _tokenInfo2.isSecondaryTokenInfoWithCacheRecord)(invalidResponse); expect(result).toBe(false); }); }); describe('parseTokenInfoResponseWithCacheRecord', () => { it('should return token info for valid token info response with cache record', () => { const validResponse = [200, _tokenInfo.tokenInfoMocks.nftCryptoKitty, 'hash', 100]; const result = (0, _tokenInfo2.parseSecondaryTokenInfoWithCacheRecord)(validResponse); expect(result).toEqual(validResponse); }); it('should return undefined for invalid token info response with cache record', () => { const invalidResponse = { data: { foo: 'bar' }, cache: 'some-cache-value' }; const result = (0, _tokenInfo2.parseSecondaryTokenInfoWithCacheRecord)(invalidResponse); expect(result).toBeUndefined(); }); }); describe('isTokenInfoWithCacheRecord', () => { it('should return true for valid token info with cache record', () => { const validRecord = { record: _tokenInfo.tokenInfoMocks.nftCryptoKitty, expires: 100, hash: 'hash' }; const result = (0, _tokenInfo2.isTokenInfoWithCacheRecord)(validRecord); expect(result).toBe(true); }); it('should return false for invalid token info with cache record', () => { const invalidRecord = { record: _tokenInfo.tokenInfoMocks.nftCryptoKitty, expires: -100, hash: 'hash' }; const result = (0, _tokenInfo2.isTokenInfoWithCacheRecord)(invalidRecord); expect(result).toBe(false); }); }); describe('parseTokenInfoWithCacheRecord', () => { it('should return token info for valid token info with cache record', () => { const validRecord = { record: _tokenInfo.tokenInfoMocks.nftCryptoKitty, expires: 100, hash: 'hash' }; const result = (0, _tokenInfo2.parseTokenInfoWithCacheRecord)(validRecord); expect(result).toEqual(validRecord); }); it('should return undefined for invalid token info with cache record', () => { const invalidRecord = { record: _tokenInfo.tokenInfoMocks.nftCryptoKitty, expires: -100, hash: 'hash' }; const result = (0, _tokenInfo2.parseTokenInfoWithCacheRecord)(invalidRecord); expect(result).toBeUndefined(); }); }); //# sourceMappingURL=token-info.test.js.map