mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-04 23:14:56 +01:00
14efbf1eea
* Add ipfs gateway and collectible state to mock-state.json * Add collectible-default-image test with snapshot and testids * Add Collectible Details test, snapshot, and test-ids * Add Collectible Options tests and test-ids * Add Collectible Items test and test-ids. * Add more tests to Add Collectible component * Update Security Tab snapshot with ipfs gateway state value * Add data-testid to Menu component for menu background * Lint * Bump coverage targets * Remove commented import --------- Co-authored-by: David Walsh <davidwalsh83@gmail.com>
81 lines
2.4 KiB
JavaScript
81 lines
2.4 KiB
JavaScript
import { fireEvent, waitFor } from '@testing-library/react';
|
|
import React from 'react';
|
|
import { renderWithProvider } from '../../../../test/lib/render-helpers';
|
|
import CollectibleOptions from './collectible-options';
|
|
|
|
describe('Collectible Options Component', () => {
|
|
const props = {
|
|
onRemove: jest.fn(),
|
|
onViewOnOpensea: jest.fn(),
|
|
};
|
|
|
|
it('should expand collectible options menu`', async () => {
|
|
const { queryByTestId } = renderWithProvider(
|
|
<CollectibleOptions {...props} />,
|
|
);
|
|
|
|
const openOptionMenuButton = queryByTestId('collectible-options__button');
|
|
|
|
expect(queryByTestId('collectible-item-remove')).not.toBeInTheDocument();
|
|
|
|
fireEvent.click(openOptionMenuButton);
|
|
|
|
await waitFor(() => {
|
|
expect(queryByTestId('collectible-item-remove')).toBeInTheDocument();
|
|
});
|
|
});
|
|
|
|
it('should expand and close menu options when clicked`', async () => {
|
|
const { queryByTestId } = renderWithProvider(
|
|
<CollectibleOptions {...props} />,
|
|
);
|
|
|
|
const openOptionMenuButton = queryByTestId('collectible-options__button');
|
|
|
|
fireEvent.click(openOptionMenuButton);
|
|
|
|
const closeOptionMenuButton = queryByTestId(
|
|
'close-collectible-options-menu',
|
|
);
|
|
|
|
fireEvent.click(closeOptionMenuButton);
|
|
|
|
expect(closeOptionMenuButton).not.toBeInTheDocument();
|
|
});
|
|
|
|
it('should click onRemove handler and close option menu', () => {
|
|
const { queryByTestId } = renderWithProvider(
|
|
<CollectibleOptions {...props} />,
|
|
);
|
|
|
|
const openOptionMenuButton = queryByTestId('collectible-options__button');
|
|
|
|
fireEvent.click(openOptionMenuButton);
|
|
|
|
const removeCollectibleButton = queryByTestId('collectible-item-remove');
|
|
|
|
fireEvent.click(removeCollectibleButton);
|
|
|
|
expect(props.onRemove).toHaveBeenCalled();
|
|
expect(removeCollectibleButton).not.toBeInTheDocument();
|
|
});
|
|
|
|
it('should click onViewOnOpensea handler and close option menu', () => {
|
|
const { queryByTestId } = renderWithProvider(
|
|
<CollectibleOptions {...props} />,
|
|
);
|
|
|
|
const openOptionMenuButton = queryByTestId('collectible-options__button');
|
|
const removeCollectibleButton = queryByTestId('collectible-item-remove');
|
|
|
|
fireEvent.click(openOptionMenuButton);
|
|
|
|
const openOpenSea = queryByTestId('collectible-options__view-on-opensea');
|
|
|
|
fireEvent.click(openOpenSea);
|
|
|
|
expect(props.onViewOnOpensea).toHaveBeenCalled();
|
|
expect(removeCollectibleButton).not.toBeInTheDocument();
|
|
});
|
|
});
|