mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
33cc8d587a
* 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
71 lines
2.2 KiB
JavaScript
71 lines
2.2 KiB
JavaScript
import { fireEvent, waitFor } from '@testing-library/react';
|
|
import React from 'react';
|
|
import { renderWithProvider } from '../../../../test/lib/render-helpers';
|
|
import NftOptions from './nft-options';
|
|
|
|
describe('NFT Options Component', () => {
|
|
const props = {
|
|
onRemove: jest.fn(),
|
|
onViewOnOpensea: jest.fn(),
|
|
};
|
|
|
|
it('should expand NFT options menu`', async () => {
|
|
const { queryByTestId } = renderWithProvider(<NftOptions {...props} />);
|
|
|
|
const openOptionMenuButton = queryByTestId('nft-options__button');
|
|
|
|
expect(queryByTestId('nft-item-remove')).not.toBeInTheDocument();
|
|
|
|
fireEvent.click(openOptionMenuButton);
|
|
|
|
await waitFor(() => {
|
|
expect(queryByTestId('nft-item-remove')).toBeInTheDocument();
|
|
});
|
|
});
|
|
|
|
it('should expand and close menu options when clicked`', async () => {
|
|
const { queryByTestId } = renderWithProvider(<NftOptions {...props} />);
|
|
|
|
const openOptionMenuButton = queryByTestId('nft-options__button');
|
|
|
|
fireEvent.click(openOptionMenuButton);
|
|
|
|
const closeOptionMenuButton = queryByTestId('close-nft-options-menu');
|
|
|
|
fireEvent.click(closeOptionMenuButton);
|
|
|
|
expect(closeOptionMenuButton).not.toBeInTheDocument();
|
|
});
|
|
|
|
it('should click onRemove handler and close option menu', () => {
|
|
const { queryByTestId } = renderWithProvider(<NftOptions {...props} />);
|
|
|
|
const openOptionMenuButton = queryByTestId('nft-options__button');
|
|
|
|
fireEvent.click(openOptionMenuButton);
|
|
|
|
const removeNftButton = queryByTestId('nft-item-remove');
|
|
|
|
fireEvent.click(removeNftButton);
|
|
|
|
expect(props.onRemove).toHaveBeenCalled();
|
|
expect(removeNftButton).not.toBeInTheDocument();
|
|
});
|
|
|
|
it('should click onViewOnOpensea handler and close option menu', () => {
|
|
const { queryByTestId } = renderWithProvider(<NftOptions {...props} />);
|
|
|
|
const openOptionMenuButton = queryByTestId('nft-options__button');
|
|
const removeNftButton = queryByTestId('nft-item-remove');
|
|
|
|
fireEvent.click(openOptionMenuButton);
|
|
|
|
const openOpenSea = queryByTestId('nft-options__view-on-opensea');
|
|
|
|
fireEvent.click(openOpenSea);
|
|
|
|
expect(props.onViewOnOpensea).toHaveBeenCalled();
|
|
expect(removeNftButton).not.toBeInTheDocument();
|
|
});
|
|
});
|