2023-02-07 19:06:37 +01:00
|
|
|
import React from 'react';
|
|
|
|
import { renderWithProvider } from '../../../../test/lib/render-helpers';
|
2023-02-16 20:23:29 +01:00
|
|
|
import NftDefaultImage from '.';
|
2023-02-07 19:06:37 +01:00
|
|
|
|
2023-02-16 20:23:29 +01:00
|
|
|
describe('NFT Default Image', () => {
|
2023-02-07 19:06:37 +01:00
|
|
|
it('should render with no props', () => {
|
2023-02-16 20:23:29 +01:00
|
|
|
const { container } = renderWithProvider(<NftDefaultImage />);
|
2023-02-07 19:06:37 +01:00
|
|
|
|
|
|
|
expect(container).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should match snapshot with all provided props', () => {
|
|
|
|
const props = {
|
2023-02-16 20:23:29 +01:00
|
|
|
name: 'NFT Name',
|
2023-02-07 19:06:37 +01:00
|
|
|
tokenId: '123',
|
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
|
|
|
clickable: true,
|
2023-02-07 19:06:37 +01:00
|
|
|
};
|
|
|
|
|
2023-02-16 20:23:29 +01:00
|
|
|
const { container } = renderWithProvider(<NftDefaultImage {...props} />);
|
2023-02-07 19:06:37 +01:00
|
|
|
|
|
|
|
expect(container).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
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
|
|
|
it('should match snapshot with missing clickable prop', () => {
|
2023-02-07 19:06:37 +01:00
|
|
|
const props = {
|
2023-02-16 20:23:29 +01:00
|
|
|
name: 'NFT Name',
|
2023-02-07 19:06:37 +01:00
|
|
|
tokenId: '123',
|
|
|
|
};
|
|
|
|
|
2023-02-16 20:23:29 +01:00
|
|
|
const { container } = renderWithProvider(<NftDefaultImage {...props} />);
|
2023-02-07 19:06:37 +01:00
|
|
|
|
|
|
|
expect(container).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
2023-02-16 20:23:29 +01:00
|
|
|
it('should render NFT name', () => {
|
2023-02-07 19:06:37 +01:00
|
|
|
const props = {
|
2023-02-16 20:23:29 +01:00
|
|
|
name: 'NFT Name',
|
2023-02-07 19:06:37 +01:00
|
|
|
};
|
|
|
|
|
2023-02-16 20:23:29 +01:00
|
|
|
const { queryByText } = renderWithProvider(<NftDefaultImage {...props} />);
|
2023-02-07 19:06:37 +01:00
|
|
|
|
2023-02-16 20:23:29 +01:00
|
|
|
const nftElement = queryByText(`${props.name} #`);
|
2023-02-07 19:06:37 +01:00
|
|
|
|
2023-02-16 20:23:29 +01:00
|
|
|
expect(nftElement).toBeInTheDocument();
|
2023-02-07 19:06:37 +01:00
|
|
|
});
|
|
|
|
|
2023-02-16 20:23:29 +01:00
|
|
|
it('should render NFT name and tokenId', () => {
|
2023-02-07 19:06:37 +01:00
|
|
|
const props = {
|
2023-02-16 20:23:29 +01:00
|
|
|
name: 'NFT Name',
|
2023-02-07 19:06:37 +01:00
|
|
|
tokenId: '123',
|
|
|
|
};
|
|
|
|
|
2023-02-16 20:23:29 +01:00
|
|
|
const { queryByText } = renderWithProvider(<NftDefaultImage {...props} />);
|
2023-02-07 19:06:37 +01:00
|
|
|
|
2023-02-16 20:23:29 +01:00
|
|
|
const nftElement = queryByText(`${props.name} #${props.tokenId}`);
|
2023-02-07 19:06:37 +01:00
|
|
|
|
2023-02-16 20:23:29 +01:00
|
|
|
expect(nftElement).toBeInTheDocument();
|
2023-02-07 19:06:37 +01:00
|
|
|
});
|
|
|
|
|
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
|
|
|
it('does not render component with clickable class when clickable is false', () => {
|
|
|
|
const { container } = renderWithProvider(
|
|
|
|
<NftDefaultImage name="NFT Name" tokenId="123" clickable={false} />,
|
2023-02-07 19:06:37 +01:00
|
|
|
);
|
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
|
|
|
expect(container.firstChild).not.toHaveClass('nft-default--clickable');
|
|
|
|
});
|
2023-02-07 19:06:37 +01:00
|
|
|
|
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
|
|
|
it('renders component with clickable class when clickable is true', () => {
|
|
|
|
const { container } = renderWithProvider(
|
|
|
|
<NftDefaultImage name="NFT Name" tokenId="123" clickable />,
|
|
|
|
);
|
|
|
|
expect(container.firstChild).toHaveClass('nft-default--clickable');
|
2023-02-07 19:06:37 +01:00
|
|
|
});
|
|
|
|
});
|