1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 19:26:13 +02:00
metamask-extension/ui/components/app/nft-default-image/nft-default-image.test.js
Nidhi Kumari 33cc8d587a
NFT: Replaced all the instances of collectibles with NFTs (#17741)
* replaced all the instances of collectibles with nfts

* updated actions

* updated e2e seeder

* updated confirm Approve test

* updated test dapp change

* updated test dapp change

* nit fix

* nit fix

* updated casing and snapshots

* updated casinG

* added migrations

* updated ,igration

* updated 078.test

* updated tests for 078 migration

* updated migration

* updated 078 index.js
2023-02-17 00:53:29 +05:30

76 lines
1.9 KiB
JavaScript

import React from 'react';
import { fireEvent } from '@testing-library/react';
import { renderWithProvider } from '../../../../test/lib/render-helpers';
import NftDefaultImage from '.';
describe('NFT Default Image', () => {
it('should render with no props', () => {
const { container } = renderWithProvider(<NftDefaultImage />);
expect(container).toMatchSnapshot();
});
it('should match snapshot with all provided props', () => {
const props = {
name: 'NFT Name',
tokenId: '123',
handleImageClick: jest.fn(),
};
const { container } = renderWithProvider(<NftDefaultImage {...props} />);
expect(container).toMatchSnapshot();
});
it('should match snapshot with missing image click handler', () => {
const props = {
name: 'NFT Name',
tokenId: '123',
};
const { container } = renderWithProvider(<NftDefaultImage {...props} />);
expect(container).toMatchSnapshot();
});
it('should render NFT name', () => {
const props = {
name: 'NFT Name',
};
const { queryByText } = renderWithProvider(<NftDefaultImage {...props} />);
const nftElement = queryByText(`${props.name} #`);
expect(nftElement).toBeInTheDocument();
});
it('should render NFT name and tokenId', () => {
const props = {
name: 'NFT Name',
tokenId: '123',
};
const { queryByText } = renderWithProvider(<NftDefaultImage {...props} />);
const nftElement = queryByText(`${props.name} #${props.tokenId}`);
expect(nftElement).toBeInTheDocument();
});
it('should handle image click', () => {
const props = {
handleImageClick: jest.fn(),
};
const { queryByTestId } = renderWithProvider(
<NftDefaultImage {...props} />,
);
const nftImageElement = queryByTestId('nft-default-image');
fireEvent.click(nftImageElement);
expect(props.handleImageClick).toHaveBeenCalled();
});
});