File size: 1,918 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 80 81 82 |
/**
* @jest-environment jsdom
*/
// @ts-nocheck - TODO: Fix TypeScript issues
import { render, screen } from '@testing-library/react';
import { translate } from 'i18n-calypso';
import React from 'react';
import { Provider } from 'react-redux';
import configureStore from 'redux-mock-store';
import { ACTIVATE_PLUGIN } from 'calypso/lib/plugins/constants';
import PluginCommonTable from '../plugin-common/plugin-common-table';
import PluginRowFormatter from '../plugin-row-formatter';
import { plugin, site } from './utils/constants';
// eslint-disable-next-line @typescript-eslint/no-empty-function
const noop = () => {};
const initialState = {
sites: { items: { [ site.ID ]: site } },
currentUser: {
capabilities: {},
},
plugins: {
installed: {
isRequesting: {},
isRequestingAll: false,
plugins: {
[ `${ site.ID }` ]: [ plugin ],
},
status: {
[ `${ site.ID }` ]: {
[ plugin.id ]: {
status: 'completed',
action: ACTIVATE_PLUGIN,
},
},
},
},
},
marketplace: {
billingInterval: {
interval: 'yearly',
},
},
productsList: [],
};
const props = {
items: [ plugin ],
isLoading: false,
columns: [
{
key: 'plugin',
header: translate( 'Installed plugins' ),
},
],
rowFormatter: function ( props ): React.ReactNode {
return <PluginRowFormatter { ...props } selectedSite={ site } updatePlugin={ noop } />;
},
primaryKey: 'id',
};
describe( '<PluginCommonTable>', () => {
const mockStore = configureStore();
const store = mockStore( initialState );
test( 'should render the columns provided and display plugin data', () => {
render(
<Provider store={ store }>
<PluginCommonTable { ...props } />
</Provider>
);
const pluginName = screen.getByRole( 'link', { name: plugin.name } );
expect( pluginName ).toHaveProperty(
'href',
`https://example.com/plugins/${ plugin.slug }/${ site.slug }`
);
} );
} );
|