2023-02-07 19:06:37 +01:00
|
|
|
import React from 'react';
|
2023-08-01 20:21:51 +02:00
|
|
|
import configureStore from 'redux-mock-store';
|
2023-02-07 19:06:37 +01:00
|
|
|
import { renderWithProvider } from '../../../../test/lib/render-helpers';
|
2023-08-01 20:21:51 +02:00
|
|
|
import mockState from '../../../../test/data/mock-state.json';
|
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-08-01 20:21:51 +02:00
|
|
|
const mockShowIpfsModal = jest.fn();
|
|
|
|
jest.mock('../../../store/actions.ts', () => ({
|
|
|
|
showIpfsModal: () => mockShowIpfsModal,
|
|
|
|
}));
|
|
|
|
|
|
|
|
const store = configureStore()(mockState);
|
|
|
|
|
2023-02-07 19:06:37 +01:00
|
|
|
it('should render with no props', () => {
|
2023-08-01 20:21:51 +02:00
|
|
|
const { container } = renderWithProvider(<NftDefaultImage />, store);
|
2023-02-07 19:06:37 +01:00
|
|
|
|
|
|
|
expect(container).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should match snapshot with all provided props', () => {
|
|
|
|
const props = {
|
2023-08-01 20:21:51 +02:00
|
|
|
clickable: false,
|
2023-02-07 19:06:37 +01:00
|
|
|
};
|
|
|
|
|
2023-08-01 20:21:51 +02:00
|
|
|
const { container } = renderWithProvider(
|
|
|
|
<NftDefaultImage {...props} />,
|
|
|
|
store,
|
|
|
|
);
|
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-08-01 20:21:51 +02:00
|
|
|
const { container } = renderWithProvider(<NftDefaultImage />, store);
|
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('does not render component with clickable class when clickable is false', () => {
|
|
|
|
const { container } = renderWithProvider(
|
2023-08-01 20:21:51 +02:00
|
|
|
<NftDefaultImage clickable={false} />,
|
|
|
|
store,
|
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(
|
2023-08-01 20:21:51 +02:00
|
|
|
<NftDefaultImage clickable />,
|
|
|
|
store,
|
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).toHaveClass('nft-default--clickable');
|
2023-02-07 19:06:37 +01:00
|
|
|
});
|
|
|
|
});
|