Multichain NFT network badges (#19029)
* adding badges for nfts
* fixing default nft styling issue
* adding multichain flag, making borderRadius inline
* Apply suggestions from code review
Co-authored-by: George Marshall <george.marshall@consensys.net>
* fixing imports
* removing nullcheck for guaranteed fields
* moving badgewrapper UI into multichain component
* using Box for button, removing inline style, border-radius for NFT default image
* adding nft badges to NFT Details page
* nits, snap update
* fixing/refactoring nftdefaultimage display, adding clickable, removing handleimageclick, refactor NFTItem, required props
* editing nft-default-image story, test, and snap
* Updating to fix positioning, use Box props to reduce CSS and BEM naming conventions
* moving minor styling to Box props, adding comment
* display block typo
---------
Co-authored-by: George Marshall <george.marshall@consensys.net>
2023-06-02 17:01:51 +02:00
|
|
|
import React from 'react';
|
2023-07-17 18:43:26 +02:00
|
|
|
import configureStore from 'redux-mock-store';
|
|
|
|
import { fireEvent } from '@testing-library/react';
|
Multichain NFT network badges (#19029)
* adding badges for nfts
* fixing default nft styling issue
* adding multichain flag, making borderRadius inline
* Apply suggestions from code review
Co-authored-by: George Marshall <george.marshall@consensys.net>
* fixing imports
* removing nullcheck for guaranteed fields
* moving badgewrapper UI into multichain component
* using Box for button, removing inline style, border-radius for NFT default image
* adding nft badges to NFT Details page
* nits, snap update
* fixing/refactoring nftdefaultimage display, adding clickable, removing handleimageclick, refactor NFTItem, required props
* editing nft-default-image story, test, and snap
* Updating to fix positioning, use Box props to reduce CSS and BEM naming conventions
* moving minor styling to Box props, adding comment
* display block typo
---------
Co-authored-by: George Marshall <george.marshall@consensys.net>
2023-06-02 17:01:51 +02:00
|
|
|
import '@testing-library/jest-dom/extend-expect';
|
2023-07-17 18:43:26 +02:00
|
|
|
import mockState from '../../../../test/data/mock-state.json';
|
|
|
|
import { renderWithProvider } from '../../../../test/lib/render-helpers';
|
Multichain NFT network badges (#19029)
* adding badges for nfts
* fixing default nft styling issue
* adding multichain flag, making borderRadius inline
* Apply suggestions from code review
Co-authored-by: George Marshall <george.marshall@consensys.net>
* fixing imports
* removing nullcheck for guaranteed fields
* moving badgewrapper UI into multichain component
* using Box for button, removing inline style, border-radius for NFT default image
* adding nft badges to NFT Details page
* nits, snap update
* fixing/refactoring nftdefaultimage display, adding clickable, removing handleimageclick, refactor NFTItem, required props
* editing nft-default-image story, test, and snap
* Updating to fix positioning, use Box props to reduce CSS and BEM naming conventions
* moving minor styling to Box props, adding comment
* display block typo
---------
Co-authored-by: George Marshall <george.marshall@consensys.net>
2023-06-02 17:01:51 +02:00
|
|
|
import { NftItem } from '.';
|
|
|
|
|
|
|
|
describe('NftItem component', () => {
|
2023-07-17 18:43:26 +02:00
|
|
|
const store = configureStore()(mockState);
|
|
|
|
describe('render', () => {
|
|
|
|
const props = {
|
|
|
|
alt: 'Test Alt',
|
|
|
|
backgroundColor: 'red',
|
|
|
|
name: 'Test NFT',
|
|
|
|
src: 'test-src',
|
|
|
|
networkName: 'Test Network',
|
|
|
|
networkSrc: 'test-network-src',
|
|
|
|
tokenId: '1',
|
|
|
|
onClick: jest.fn(),
|
|
|
|
};
|
|
|
|
|
|
|
|
it('renders correctly with an image source', () => {
|
|
|
|
const { getByTestId } = renderWithProvider(<NftItem {...props} />, store);
|
|
|
|
|
|
|
|
expect(getByTestId('nft-item')).toBeInTheDocument();
|
|
|
|
expect(getByTestId('nft-network-badge')).toBeInTheDocument();
|
|
|
|
expect(getByTestId('nft-image')).toBeInTheDocument();
|
|
|
|
expect(getByTestId('nft-image')).toHaveAttribute('src', 'test-src');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders correctly with default image when no image source is provided', () => {
|
|
|
|
const { getByTestId, queryByTestId } = renderWithProvider(
|
|
|
|
<NftItem {...props} src="" />,
|
|
|
|
store,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(queryByTestId('nft-image')).not.toBeInTheDocument();
|
|
|
|
expect(getByTestId('nft-default-image')).toBeInTheDocument();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('calls onClick when the NFT image is clicked', () => {
|
|
|
|
const { getByTestId } = renderWithProvider(<NftItem {...props} />, store);
|
|
|
|
|
|
|
|
fireEvent.click(getByTestId('nft-image'));
|
|
|
|
expect(props.onClick).toHaveBeenCalled();
|
|
|
|
});
|
Multichain NFT network badges (#19029)
* adding badges for nfts
* fixing default nft styling issue
* adding multichain flag, making borderRadius inline
* Apply suggestions from code review
Co-authored-by: George Marshall <george.marshall@consensys.net>
* fixing imports
* removing nullcheck for guaranteed fields
* moving badgewrapper UI into multichain component
* using Box for button, removing inline style, border-radius for NFT default image
* adding nft badges to NFT Details page
* nits, snap update
* fixing/refactoring nftdefaultimage display, adding clickable, removing handleimageclick, refactor NFTItem, required props
* editing nft-default-image story, test, and snap
* Updating to fix positioning, use Box props to reduce CSS and BEM naming conventions
* moving minor styling to Box props, adding comment
* display block typo
---------
Co-authored-by: George Marshall <george.marshall@consensys.net>
2023-06-02 17:01:51 +02:00
|
|
|
});
|
|
|
|
});
|