File size: 3,092 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
/** @jest-environment jsdom */
import { render, screen } from '@testing-library/react';
import isAtomicSite from 'calypso/state/selectors/is-site-automated-transfer';
import { isJetpackSite } from 'calypso/state/sites/selectors';
import PluginsBrowserListElement from '../';
jest.mock( 'calypso/lib/analytics/tracks', () => ( {} ) );
jest.mock( 'calypso/lib/analytics/page-view', () => ( {} ) );
jest.mock( 'calypso/state/ui/selectors' );
jest.mock( 'calypso/state/plugins/installed/selectors' );
jest.mock( 'calypso/state/products-list/selectors' );
jest.mock( 'calypso/state/sites/selectors' );
jest.mock( 'calypso/state/selectors/is-site-automated-transfer' );
jest.mock( 'react-redux', () => ( {
...jest.requireActual( 'react-redux' ),
useDispatch: jest.fn().mockImplementation( () => {} ),
useSelector: jest.fn().mockImplementation( ( selector ) => selector( {} ) ),
} ) );
jest.mock( 'calypso/my-sites/plugins/use-preinstalled-premium-plugin', () =>
jest.fn( () => ( { usePreinstalledPremiumPlugin: jest.fn() } ) )
);
jest.mock( 'calypso/state/plugins/last-visited/selectors', () => ( {
isLastVisitedPlugin: () => {},
} ) );
describe( 'PluginsBrowserItem Incompatible Plugins Message', () => {
test( 'should render the incompatible plugin message on Simple Sites', () => {
isJetpackSite.mockImplementation( () => false );
isAtomicSite.mockImplementation( () => false );
const props = {
plugin: { name: 'wordfence', slug: 'wordfence' },
};
render( <PluginsBrowserListElement { ...props } /> );
const message = screen.queryByText( 'Why is this plugin not compatible with WordPress.com?' );
expect( message ).toBeInTheDocument();
} );
test( 'should render the incompatible plugin message on Atomic Sites', () => {
isJetpackSite.mockImplementation( () => true );
isAtomicSite.mockImplementation( () => true );
const props = {
plugin: { name: 'wordfence', slug: 'wordfence' },
};
render( <PluginsBrowserListElement { ...props } /> );
const message = screen.queryByText( 'Why is this plugin not compatible with WordPress.com?' );
expect( message ).toBeInTheDocument();
} );
test( 'should NOT render the incompatible plugin message on JetpackSite non Atomic sites', () => {
isJetpackSite.mockImplementation( () => true );
isAtomicSite.mockImplementation( () => false );
const props = {
plugin: { name: 'wordfence', slug: 'wordfence' },
};
render( <PluginsBrowserListElement { ...props } /> );
const message = screen.queryByText( 'Why is this plugin not compatible with WordPress.com?' );
expect( message ).not.toBeInTheDocument();
} );
test( 'should NOT render the incompatible plugin message if it is not in the list', () => {
isJetpackSite.mockImplementation( () => true );
isAtomicSite.mockImplementation( () => false );
const props = {
plugin: { name: 'woocommerce', slug: 'woocommerce' },
};
render( <PluginsBrowserListElement { ...props } /> );
const message = screen.queryByText( 'Why is this plugin not compatible with WordPress.com?' );
expect( message ).not.toBeInTheDocument();
} );
} );
|