balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

index.test.js (2397B)


      1 import renderer from 'react-test-renderer';
      2 import {mount, shallow} from 'enzyme';
      3 import DependentPlugins from '..';
      4 import {SingleItemProvider} from '../../../contexts/SingleItemContext';
      5 
      6 window.redux-templates = {
      7     supported_plugins: {
      8         ugb: {
      9             name: 'Stackable',
     10             url: 'https://wpstackable.com/premium/#pricing-table',
     11             has_pro: true,
     12             slug: 'stackable-ultimate-gutenberg-blocks',
     13             premium_slug: 'stackable-ultimate-gutenberg-blocks-premium'
     14         },
     15         qubely: {
     16             name: 'Qubely',
     17             url: 'https://www.themeum.com/qubely-pricing/',
     18             has_pro: true,
     19             premium_slug: 'qubely-pro'
     20         }
     21     }
     22 }
     23 
     24 const singleMock = {
     25     data: {ID: 1, blocks: {}},
     26     showDependencyBlock: true
     27 };
     28 
     29 const WrappedDependentPlugins = (props) => {
     30     const {singleValue} = props;
     31     return (
     32         <SingleItemProvider value={{...singleMock, ...singleValue}}>
     33             <DependentPlugins />
     34         </SingleItemProvider>
     35     );
     36 }
     37 
     38 describe('Dependent Plugins part within Button Group component', () => {
     39     it('1. renders correctly: snapshot testing', () => {
     40         const component = renderer.create(
     41             <WrappedDependentPlugins />
     42         );
     43         const tree = component.toJSON();
     44         expect(tree).toMatchSnapshot();
     45     });
     46 
     47     describe('2. Testing props', () => {
     48         it('renders nothing when showDependencyBlock of SingleItemProvider is false', () => {
     49             const component = shallow(
     50                 <WrappedDependentPlugins singleValue={{showDependencyBlock: false}} />
     51             );
     52             expect(component.html()).toBeFalsy();
     53         });
     54 
     55         it('renders just wrapper .redux-templates-button-display-dependencies when no blocks data is given', () => {
     56             const component = mount(
     57                 <WrappedDependentPlugins />
     58             );
     59             expect(component.find('.redux-templates-button-display-dependencies').text()).toBe('');
     60         });
     61 
     62 
     63         it('renders blocks dependency plugins when dependency plugins data are provided', () => {
     64             const component = mount(
     65                 <WrappedDependentPlugins singleValue={{data: {blocks: {qubely: [], ugb: []}}}} />
     66             );
     67             expect(component.find('.redux-templates-button-display-dependencies').children()).toHaveLength(2);
     68         });
     69     });
     70 
     71 });