File size: 1,216 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
/**
 * @jest-environment jsdom
 */
// @ts-nocheck - TODO: Fix TypeScript issues
import { render } from '@testing-library/react';
import React from 'react';
import { Provider } from 'react-redux';
import configureStore from 'redux-mock-store';
import PluginManageConnection from '../plugin-manage-connection';
import { site, plugin } from './utils/constants';

const props = {
	site,
	plugin,
};

describe( '<PluginManageConnection>', () => {
	const mockStore = configureStore();
	const store = mockStore( {} );

	test( 'should render correctly and return null', () => {
		const { container } = render(
			<Provider store={ store }>
				<PluginManageConnection { ...props } />
			</Provider>
		);

		expect( container ).toBeEmptyDOMElement();
	} );

	test( 'should render correctly and show manage connection', () => {
		plugin.slug = 'jetpack';
		const { container } = render(
			<Provider store={ store }>
				<PluginManageConnection { ...props } />
			</Provider>
		);

		const [ manageConnection ] = container.getElementsByClassName(
			'plugin-management-v2__actions'
		);
		expect( manageConnection ).toHaveProperty(
			'href',
			`https://example.com/settings/manage-connection/${ site.slug }`
		);
	} );
} );