forked from input-output-hk/daedalus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request input-output-hk#2904 from input-output-hk/feature/…
…ddw-942-display-ascii-when-token-has-no-name [DDW-942] Design ASCII display for when a token doesn't have a name
- Loading branch information
Showing
6 changed files
with
103 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import React from 'react'; | ||
import BigNumber from 'bignumber.js'; | ||
import { render, screen, cleanup } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import Asset from './Asset'; | ||
import { TestDecorator } from '../../../../../tests/_utils/TestDecorator'; | ||
|
||
const assetWithMetadataName = { | ||
policyId: 'policyId', | ||
assetName: '54657374636f696e', | ||
quantity: new BigNumber(1), | ||
fingerprint: 'fingerprint', | ||
metadata: { | ||
name: 'Testcoin', | ||
description: 'Test coin', | ||
}, | ||
uniqueId: 'uniqueId', | ||
decimals: 1, | ||
recommendedDecimals: null, | ||
}; | ||
const assetWitoutMetadataName = { | ||
policyId: 'policyId', | ||
assetName: '436f696e74657374', | ||
quantity: new BigNumber(1), | ||
fingerprint: 'fingerprint', | ||
uniqueId: 'uniqueId', | ||
decimals: 1, | ||
recommendedDecimals: null, | ||
}; | ||
const assetWithoutName = { | ||
policyId: 'policyId', | ||
assetName: '', | ||
quantity: new BigNumber(1), | ||
fingerprint: 'fingerprint', | ||
uniqueId: 'uniqueId', | ||
decimals: 1, | ||
recommendedDecimals: null, | ||
}; | ||
|
||
describe('Asset', () => { | ||
afterEach(cleanup); | ||
|
||
test('Should display asset metadata name', () => { | ||
render( | ||
<TestDecorator> | ||
<Asset asset={assetWithMetadataName} /> | ||
</TestDecorator> | ||
); | ||
expect(screen.queryByTestId('assetName')).toHaveTextContent('Testcoin'); | ||
}); | ||
|
||
test('Should display asset ASCII name when metadata name is not available', () => { | ||
render( | ||
<TestDecorator> | ||
<Asset asset={assetWitoutMetadataName} /> | ||
</TestDecorator> | ||
); | ||
expect(screen.queryByTestId('assetName')).toHaveTextContent( | ||
'ASCII: Cointest' | ||
); | ||
}); | ||
|
||
test('Should not display asset name when metadata and ASCII name are not available', () => { | ||
render( | ||
<TestDecorator> | ||
<Asset asset={assetWithoutName} /> | ||
</TestDecorator> | ||
); | ||
expect(screen.queryByTestId('assetName')).toBeNull(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters