|
| 1 | +import React from 'react'; |
| 2 | +import BigNumber from 'bignumber.js'; |
| 3 | +import { render, screen, cleanup } from '@testing-library/react'; |
| 4 | +import '@testing-library/jest-dom'; |
| 5 | +import Asset from './Asset'; |
| 6 | +import { TestDecorator } from '../../../../../tests/_utils/TestDecorator'; |
| 7 | + |
| 8 | +const assets = [ |
| 9 | + { |
| 10 | + policyId: 'policyId', |
| 11 | + assetName: '54657374636f696e', |
| 12 | + quantity: new BigNumber(1), |
| 13 | + fingerprint: 'fingerprint', |
| 14 | + metadata: { |
| 15 | + name: 'Testcoin', |
| 16 | + description: 'Test coin', |
| 17 | + }, |
| 18 | + uniqueId: 'uniqueId', |
| 19 | + decimals: 1, |
| 20 | + recommendedDecimals: null, |
| 21 | + }, |
| 22 | + { |
| 23 | + policyId: 'policyId', |
| 24 | + assetName: '436f696e74657374', |
| 25 | + quantity: new BigNumber(1), |
| 26 | + fingerprint: 'fingerprint', |
| 27 | + uniqueId: 'uniqueId', |
| 28 | + decimals: 1, |
| 29 | + recommendedDecimals: null, |
| 30 | + }, |
| 31 | + { |
| 32 | + policyId: 'policyId', |
| 33 | + assetName: '', |
| 34 | + quantity: new BigNumber(1), |
| 35 | + fingerprint: 'fingerprint', |
| 36 | + uniqueId: 'uniqueId', |
| 37 | + decimals: 1, |
| 38 | + recommendedDecimals: null, |
| 39 | + }, |
| 40 | +]; |
| 41 | + |
| 42 | +describe('Asset', () => { |
| 43 | + afterEach(cleanup); |
| 44 | + |
| 45 | + test('Should display asset metadata name', () => { |
| 46 | + render( |
| 47 | + <TestDecorator> |
| 48 | + <Asset asset={assets[0]} /> |
| 49 | + </TestDecorator> |
| 50 | + ); |
| 51 | + expect(screen.queryByTestId('assetName')).toHaveTextContent('Testcoin'); |
| 52 | + }); |
| 53 | + |
| 54 | + test('Should display asset ASCII name', () => { |
| 55 | + render( |
| 56 | + <TestDecorator> |
| 57 | + <Asset asset={assets[1]} /> |
| 58 | + </TestDecorator> |
| 59 | + ); |
| 60 | + expect(screen.queryByTestId('assetName')).toHaveTextContent( |
| 61 | + 'ASCII: Cointest' |
| 62 | + ); |
| 63 | + }); |
| 64 | + |
| 65 | + test('Should display empty name', () => { |
| 66 | + render( |
| 67 | + <TestDecorator> |
| 68 | + <Asset asset={assets[2]} /> |
| 69 | + </TestDecorator> |
| 70 | + ); |
| 71 | + expect(screen.queryByTestId('assetName')).toBeNull(); |
| 72 | + }); |
| 73 | +}); |
0 commit comments